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 N = 5e5 + 10;
int n, q, l, r;
char s[N];
struct node {
  int l, r, pl, pr, plr, prl, sl, sr, slr, srl, mxlr, mxrl;
  bool tag;
  void init() {
    pl = pr = plr = prl = sl = sr = slr = srl = mxlr = mxrl = tag = 0;
  }
  void out() {
    printf(
        "l:%d r:%d pl:%d pr:%d plr:%d prl:%d sl:%d sr:%d slr:%d srl:%d mxlr:%d "
        "mxrl:%d\n",
        l, r, pl, pr, plr, prl, sl, sr, slr, srl, mxlr, mxrl);
  }
  node() { init(); }
} e[5 * N];
node merge(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 > 0) c.plr = a.pl + b.pr;
    if (b.plr > 0) 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 > 0) c.prl = a.pr + b.pl;
    if (b.prl > 0) 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 > 0) c.slr = a.sl + b.sr;
    if (a.slr > 0) c.slr = a.slr + b.sr;
  }
  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 > 0) c.srl = a.sr + b.sl;
    if (a.srl > 0) c.srl = a.srl + b.sl;
  }
  c.mxlr = max(c.plr, c.slr);
  if (a.sl > 0 && b.pr > 0) c.mxlr = max(c.mxlr, a.sl + b.pr);
  if (b.plr > 0) c.mxlr = max(c.mxlr, a.sl + b.plr);
  if (a.slr > 0) c.mxlr = max(c.mxlr, a.slr + b.pr);
  c.mxlr = max(c.mxlr, max(a.mxlr, b.mxlr));
  c.mxrl = max(c.prl, c.srl);
  if (a.sr > 0 && b.pl > 0) c.mxrl = max(c.mxrl, a.sr + b.pl);
  if (b.prl > 0) c.mxrl = max(c.mxrl, a.sr + b.prl);
  if (a.srl > 0) c.mxrl = max(c.mxrl, a.srl + b.pl);
  c.mxrl = max(c.mxrl, max(a.mxrl, b.mxrl));
  return c;
}
void bld(int p, int l, int r) {
  e[p].init();
  e[p].l = l, e[p].r = r;
  if (l == r) {
    if (s[l] == '<')
      e[p].pl = e[p].sl = 1;
    else
      e[p].pr = e[p].sr = 1;
    return;
  }
  int mid = (l + r) / 2;
  bld(p << 1, l, mid);
  bld(p << 1 | 1, mid + 1, r);
  e[p] = merge(e[p << 1], e[p << 1 | 1]);
}
void flip(int p) {
  swap(e[p].pl, e[p].pr), swap(e[p].sl, e[p].sr);
  swap(e[p].plr, e[p].prl), swap(e[p].slr, e[p].srl),
      swap(e[p].mxlr, e[p].mxrl);
  e[p].tag ^= 1;
}
void psd(int p) {
  if (e[p].tag) {
    flip(p << 1), flip(p << 1 | 1);
    e[p].tag = 0;
  }
}
node ask(int p, int ql, int qr) {
  if (e[p].l == ql && e[p].r == qr) {
    flip(p);
    return e[p];
  }
  psd(p);
  int mid = (e[p].l + e[p].r) / 2;
  node ans;
  if (qr <= mid)
    ans = ask(p << 1, ql, qr);
  else if (ql > mid)
    ans = ask(p << 1 | 1, ql, qr);
  else
    ans = merge(ask(p << 1, ql, mid), ask(p << 1 | 1, mid + 1, qr));
  e[p] = merge(e[p << 1], e[p << 1 | 1]);
  return ans;
}
int main() {
  scanf("%d%d", &n, &q);
  scanf("%s", s + 1);
  bld(1, 1, n);
  while (q--) {
    scanf("%d%d", &l, &r);
    node ans = ask(1, l, r);
    printf("%d\n", max(ans.mxrl, max(ans.pl, ans.sr)));
  }
  return 0;
}