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;
const int maxn = 5e5 + 10;
struct node {
  int pl, pr, sl, sr, mxlr, mxrl, slr, srl, plr, prl;
  int l, r, lz;
  node() { pl = pr = sl = sr = mxlr = mxrl = slr = srl = plr = prl = lz = 0; }
};
node arr[maxn << 2];
char str[maxn];
int n, q;
node pushup(node a, node b) {
  node c;
  c.l = a.l;
  c.r = b.r;
  c.pl = a.pl;
  if (a.pl == a.r - a.l + 1) c.pl += b.pl;
  c.pr = a.pr;
  if (a.pr == a.r - a.l + 1) c.pr += b.pr;
  c.sl = b.sl;
  if (b.sl == b.r - b.l + 1) c.sl += a.sl;
  c.sr = b.sr;
  if (b.sr == b.r - b.l + 1) c.sr += a.sr;
  c.plr = a.plr;
  if (a.plr == a.r - a.l + 1) c.plr += b.pr;
  if (a.pl == a.r - a.l + 1) {
    if (b.pr) c.plr = a.pl + b.pr;
    if (b.plr) c.plr = a.pl + b.plr;
  }
  c.prl = a.prl;
  if (a.prl == a.r - a.l + 1) c.prl += b.pl;
  if (a.pr == a.r - a.l + 1) {
    if (b.pl) c.prl = a.pr + b.pl;
    if (b.prl) c.prl = a.pr + b.prl;
  }
  c.slr = b.slr;
  if (b.slr == b.r - b.l + 1) c.slr += a.sl;
  if (b.sr == b.r - b.l + 1) {
    if (a.sl) c.slr = b.sr + a.sl;
    if (a.slr) c.slr = b.sr + a.slr;
  }
  c.srl = b.srl;
  if (b.srl == b.r - b.l + 1) c.srl += a.sr;
  if (b.sl == b.r - b.l + 1) {
    if (a.sr) c.srl = b.sl + a.sr;
    if (a.srl) c.srl = b.sl + a.srl;
  }
  c.mxlr = max(c.slr, c.plr);
  if (a.sl && b.pr) c.mxlr = max(c.mxlr, a.sl + b.pr);
  if (b.plr) c.mxlr = max(c.mxlr, b.plr + a.sl);
  if (a.slr) c.mxlr = max(c.mxlr, a.slr + b.pr);
  c.mxlr = max(c.mxlr, max(a.mxlr, b.mxlr));
  c.mxrl = max(c.srl, c.prl);
  if (a.sr && b.pl) c.mxrl = max(c.mxrl, a.sr + b.pl);
  if (b.prl) c.mxrl = max(c.mxrl, b.prl + a.sr);
  if (a.srl) c.mxrl = max(c.mxrl, a.srl + b.pl);
  c.mxrl = max(c.mxrl, max(a.mxrl, b.mxrl));
  return c;
}
void build(int o, int L, int R) {
  arr[o].l = L;
  arr[o].r = R;
  if (L == R) {
    if (str[L] == '<')
      arr[o].pl = arr[o].sl = 1;
    else
      arr[o].pr = arr[o].sr = 1;
    return;
  }
  int mid = (L + R) / 2;
  build(o << 1, L, mid);
  build(o << 1 | 1, mid + 1, R);
  arr[o] = pushup(arr[o << 1], arr[o << 1 | 1]);
}
void rev(int o) {
  swap(arr[o].pl, arr[o].pr);
  swap(arr[o].sl, arr[o].sr);
  swap(arr[o].slr, arr[o].srl);
  swap(arr[o].plr, arr[o].prl);
  swap(arr[o].mxlr, arr[o].mxrl);
  arr[o].lz ^= 1;
}
void pushdown(int o) {
  if (!arr[o].lz) return;
  rev(o << 1);
  rev(o << 1 | 1);
  arr[o].lz = 0;
}
node query(int o, int L, int R, int l, int r) {
  if (l <= L && R <= r) {
    rev(o);
    return arr[o];
  }
  pushdown(o);
  int mid = (L + R) / 2;
  node ret;
  if (r <= mid)
    ret = query(o << 1, L, mid, l, r);
  else if (l > mid)
    ret = query(o << 1 | 1, mid + 1, R, l, r);
  else
    ret = pushup(query(o << 1, L, mid, l, r),
                 query(o << 1 | 1, mid + 1, R, l, r));
  arr[o] = pushup(arr[o << 1], arr[o << 1 | 1]);
  return ret;
}
int main() {
  scanf("%d%d", &n, &q);
  scanf("%s", str + 1);
  build(1, 1, n);
  while (q--) {
    int L, R;
    scanf("%d%d", &L, &R);
    auto x = query(1, 1, n, L, R);
    int ans = max(x.mxrl, max(x.pl, x.sr));
    printf("%d\n", ans);
  }
  return 0;
}