Problem: You are a warrior fighting against the machine god Thor.

Thor challenge you to solve the following problem:

There are n conveyors arranged in a line numbered with integers from 1 to n from left to right. Each conveyor has a symbol "<" or ">". The initial state of the conveyor i is equal to the i-th character of the string s. There are n+1 holes numbered with integers from 0 to n. The hole 0 is on the left side of the conveyor 1, and for all i ≥ 1 the hole i is on the right side of the conveyor i.

When a ball is on the conveyor i, the ball moves by the next rules:

If the symbol "<" is on the conveyor i, then:

  * If i=1, the ball falls into the hole 0. 
  * If the symbol "<" is on the conveyor i-1, the ball moves to the conveyor i-1. 
  * If the symbol ">" is on the conveyor i-1, the ball falls into the hole i-1. 



If the symbol ">" is on the conveyor i, then:

  * If i=n, the ball falls into the hole n. 
  * If the symbol ">" is on the conveyor i+1, the ball moves to the conveyor i+1. 
  * If the symbol "<" is on the conveyor i+1, the ball falls into the hole i. 



You should answer next q queries, each query is defined by the pair of integers l, r (1 ≤ l ≤ r ≤ n): 

  * First, for all conveyors l,l+1,...,r, the symbol "<" changes to ">" and vice versa. These changes remain for the next queries.
  * After that, put one ball on each conveyor l,l+1,...,r. Then, each ball falls into some hole. Find the maximum number of balls in one hole. After the query all balls disappear and don't considered in the next queries.

Input

The first line contains two integers n, q (1 ≤ n ≤ 5 × 10^5 , 1 ≤ q ≤ 10^5).

The second line contains a string s of length n. It consists of characters "<" and ">". 

Next q lines contain the descriptions of the queries, i-th of them contains two integers l, r (1 ≤ l ≤ r ≤ n), describing the i-th query.

Output

Print q lines, in the i-th of them print the answer to the i-th query.

Example

Input


5 6
&gt;&lt;&gt;&gt;&lt;
2 4
3 5
1 5
1 3
2 4
1 5


Output


3
3
5
3
2
3

Note

  * In the first query, the conveyors change to ">><<<". After that, put a ball on each conveyor \{2,3,4\}. All three balls fall into the hole 2. So the answer is 3. 
  * In the second query, the conveyors change to ">>>>>". After that, put a ball on each conveyor \{3,4,5\}. All three balls fall into the hole 5. So the answer is 3. 
  * In the third query, the conveyors change to "<<<<<". After that, put a ball on each conveyor \{1,2,3,4,5\}. All five balls fall into the hole 0. So the answer is 5. 
  * In the fourth query, the conveyors change to ">>><<". After that, put a ball on each conveyor \{1,2,3\}. All three balls fall into the hole 3. So the answer is 3. 
  * In the fifth query, the conveyors change to "><<><". After that, put a ball on each conveyor \{2,3,4\}. Two balls fall into the hole 1, and one ball falls into the hole 4. So, the answer is 2. 
  * In the sixth query, the conveyors change to "<>><>". After that, put a ball on each conveyor \{1,2,3,4,5\}. Three balls fall into the hole 3, one ball falls into the hole 0 and one ball falls into the hole 5. So, the answer is 3. 

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
long long M = 1e9 + 7;
struct node {
  int sz;
  int knd[2];
  int len[2];
  int slen[2];
  int mx[2];
};
node operator+(const node& s, const node& t) {
  node res;
  res.sz = s.sz + t.sz;
  res.knd[0] = s.knd[0];
  res.knd[1] = t.knd[1];
  if (s.len[0] < s.sz || s.knd[0] != t.knd[0])
    res.len[0] = s.len[0];
  else
    res.len[0] = s.len[0] + t.len[0];
  if (t.len[1] < t.sz || s.knd[1] != t.knd[1])
    res.len[1] = t.len[1];
  else
    res.len[1] = s.len[1] + t.len[1];
  if (res.len[1] != res.sz) {
    if (s.len[0] == s.sz) {
      if (s.knd[0] == t.knd[0])
        res.slen[0] = t.slen[0];
      else
        res.slen[0] = t.len[0];
    } else {
      if (s.slen[0] + s.len[0] == s.sz && s.knd[0] != t.knd[0])
        res.slen[0] = s.slen[0] + t.len[0];
      else
        res.slen[0] = s.slen[0];
    }
    if (t.len[1] == t.sz) {
      if (s.knd[1] == t.knd[1])
        res.slen[1] = s.slen[1];
      else
        res.slen[1] = s.len[1];
    } else {
      if (t.slen[1] + t.len[1] == t.sz && t.knd[1] != s.knd[1])
        res.slen[1] = t.slen[1] + s.len[1];
      else
        res.slen[1] = t.slen[1];
    }
  } else
    res.slen[0] = res.slen[1] = 0;
  res.mx[0] = max(s.mx[0], t.mx[0]);
  res.mx[1] = max(s.mx[1], t.mx[1]);
  if (s.knd[1] == 1 && t.knd[0] == 0)
    res.mx[0] = max(res.mx[0], s.len[1] + t.len[0]);
  if (s.knd[1] == 0 && t.knd[0] == 1)
    res.mx[1] = max(res.mx[1], s.len[1] + t.len[0]);
  if (s.knd[1] == 1 && t.knd[0] == 1) {
    res.mx[0] = max(res.mx[0], s.len[1] + t.len[0] + t.slen[0]);
    res.mx[1] = max(res.mx[1], s.slen[1] + s.len[1] + t.len[0]);
  }
  if (s.knd[1] == 0 && t.knd[0] == 0) {
    res.mx[0] = max(res.mx[0], s.slen[1] + s.len[1] + t.len[0]);
    res.mx[1] = max(res.mx[1], s.len[1] + t.len[0] + t.slen[0]);
  }
  return res;
}
void operator~(node& s) {
  s.knd[0] ^= 1;
  s.knd[1] ^= 1;
  swap(s.mx[0], s.mx[1]);
}
const int N = 5e5 + 7;
node seg[N * 4];
bool laz[N * 4];
int n, q;
string str;
void prep(int v = 1, int s = 1, int e = n + 1) {
  if (e - s == 1) {
    seg[v].len[0] = seg[v].len[1] = 1;
    if (str[s - 1] == '>') seg[v].knd[0] = seg[v].knd[1] = 1;
    seg[v].mx[0] = seg[v].mx[1] = seg[v].sz = 1;
    return;
  }
  prep((v * 2), s, ((s + e) / 2));
  prep((v * 2 + 1), ((s + e) / 2), e);
  seg[v] = seg[(v * 2)] + seg[(v * 2 + 1)];
}
void spl(int v) {
  for (int u = (v * 2); u <= (v * 2 + 1); u++)
    if (laz[v]) {
      ~seg[u];
      laz[u] ^= 1;
    }
  laz[v] = 0;
}
void rev(int l, int r, int v = 1, int s = 1, int e = n + 1) {
  if (r <= s || e <= l) return;
  if (l <= s && e <= r) {
    ~seg[v];
    laz[v] ^= 1;
    return;
  }
  spl(v);
  rev(l, r, (v * 2), s, ((s + e) / 2));
  rev(l, r, (v * 2 + 1), ((s + e) / 2), e);
  seg[v] = seg[(v * 2)] + seg[(v * 2 + 1)];
}
node get(int l, int r, int v = 1, int s = 1, int e = n + 1) {
  if (r <= s || e <= l) return seg[0];
  if (l <= s && e <= r) {
    return seg[v];
  }
  spl(v);
  return get(l, r, (v * 2), s, ((s + e) / 2)) +
         get(l, r, (v * 2 + 1), ((s + e) / 2), e);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  cin >> str;
  prep();
  while (q--) {
    int l, r;
    cin >> l >> r;
    rev(l, r + 1);
    node s = get(l, r + 1);
    cout << s.mx[0] << ' ';
  }
}