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 T = 1 << 19;
struct nod {
  int best = 0, best2 = 0;
  int pref0 = 0, pref1 = 0, suf0 = 0, suf1 = 0;
  int pref01 = 0, pref10 = 0, suf01 = 0, suf10 = 0;
  int cnt0 = 0, cnt1 = 0;
};
void umax(int &a, int b) { a = max(a, b); }
nod merge(nod a, nod b) {
  nod c;
  c.cnt0 = a.cnt0 + b.cnt0;
  c.cnt1 = a.cnt1 + b.cnt1;
  c.best = max({a.best, b.best, a.suf01 + b.pref1, a.suf0 + b.pref01});
  c.best2 = max({a.best2, b.best2, a.suf10 + b.pref0, a.suf1 + b.pref10});
  c.suf0 = (b.cnt1 == 0 ? b.suf0 + a.suf0 : b.suf0);
  c.suf1 = (b.cnt0 == 0 ? b.suf1 + a.suf1 : b.suf1);
  c.pref0 = (a.cnt1 == 0 ? a.pref0 + b.pref0 : a.pref0);
  c.pref1 = (a.cnt0 == 0 ? a.pref1 + b.pref1 : a.pref1);
  c.pref01 = (a.cnt1 == 0 ? a.cnt0 + b.pref01 : a.pref01);
  if (a.pref01 == a.cnt0 + a.cnt1) umax(c.pref01, a.pref01 + b.pref1);
  umax(c.pref01, max(c.pref0, c.pref1));
  c.pref10 = (a.cnt0 == 0 ? a.cnt1 + b.pref10 : a.pref10);
  if (a.pref10 == a.cnt0 + a.cnt1) umax(c.pref10, a.pref10 + b.pref0);
  umax(c.pref10, max(c.pref0, c.pref1));
  c.suf01 = (b.cnt0 == 0 ? b.cnt1 + a.suf01 : b.suf01);
  if (b.suf01 == b.cnt0 + b.cnt1) umax(c.suf01, b.suf01 + a.suf0);
  umax(c.suf01, max(c.suf0, c.suf1));
  c.suf10 = (b.cnt1 == 0 ? b.cnt0 + a.suf10 : b.suf10);
  if (b.suf10 == b.cnt0 + b.cnt1) umax(c.suf10, b.suf10 + a.suf1);
  umax(c.suf10, max(c.suf0, c.suf1));
  return c;
}
nod t[T + T];
bool tag[T + T];
int n, m;
char s[T];
void odwroc(int v) {
  swap(t[v].best, t[v].best2);
  swap(t[v].cnt0, t[v].cnt1);
  swap(t[v].pref01, t[v].pref10);
  swap(t[v].suf01, t[v].suf10);
  swap(t[v].pref0, t[v].pref1);
  swap(t[v].suf0, t[v].suf1);
}
void push(int v) {
  if (!tag[v]) return;
  for (auto u : {2 * v, 2 * v + 1}) {
    tag[u] ^= 1;
    odwroc(u);
  }
  tag[v] = 0;
}
void invert(int x, int y, int v = 1, int l = 0, int r = T - 1) {
  if (x <= l && r <= y) {
    tag[v] ^= 1;
    odwroc(v);
    return;
  }
  push(v);
  int m = (l + r) / 2;
  if (x <= m) invert(x, y, 2 * v, l, m);
  if (m < y) invert(x, y, 2 * v + 1, m + 1, r);
  t[v] = merge(t[2 * v], t[2 * v + 1]);
}
nod query(int x, int y, int v = 1, int l = 0, int r = T - 1) {
  if (x <= l && r <= y) {
    return t[v];
  }
  push(v);
  nod res;
  int m = (l + r) / 2;
  if (x <= m) res = merge(res, query(x, y, 2 * v, l, m));
  if (m < y) res = merge(res, query(x, y, 2 * v + 1, m + 1, r));
  return res;
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%s", s + 1);
  for (int i = 1; i <= n; ++i) {
    int v = i + T;
    t[v].best = 1;
    if (s[i] == '>')
      t[v].pref0 = t[v].suf0 = t[v].pref01 = t[v].pref10 = t[v].suf01 =
          t[v].suf10 = t[v].cnt0 = t[v].best2 = 1;
    else
      t[v].pref1 = t[v].suf1 = t[v].pref01 = t[v].pref10 = t[v].suf01 =
          t[v].suf10 = t[v].cnt1 = t[v].best2 = 1;
  }
  for (int i = T - 1; 1 <= i; --i) t[i] = merge(t[2 * i], t[2 * i + 1]);
  while (m--) {
    int a, b;
    scanf("%d%d", &a, &b);
    invert(a, b);
    printf("%d\n", query(a, b).best);
  }
  return 0;
}