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 INF = 0x3f3f3f3f;
struct node {
  bool c1, c2;
  int mini, maxi, res;
};
const int MAXN = 1 << 19;
node segtree[MAXN * 2 + 2][2];
char init[MAXN];
struct BIT {
  int bit[MAXN + 10] = {0}, n = MAXN;
  int sum(int i) {
    int s = 0;
    while (i > 0) {
      s += bit[i];
      i -= i & (-i);
    }
    return s;
  }
  int query(int l, int r) { return sum(r) - sum(l - 1); }
  void add(int i, int x = 1) {
    while (i <= n) {
      bit[i] += x;
      i += i & (-i);
    }
  }
} bit;
char RRverse(char c) {
  if (c == '<') {
    return '>';
  }
  return '<';
}
char Reverse(int pos) {
  if (bit.query(1, pos) & 1) {
    return init[pos];
  } else {
    if (init[pos] == '<') return '>';
  }
  return '<';
}
bool nei(char c1, char c2) { return (c1 == '<') && (c2 == '>'); }
void merge(node& rest, node A, node B, bool flag, int r1) {
  rest.mini = min(A.mini, B.mini);
  rest.maxi = max(A.maxi, B.maxi);
  rest.res = max(A.res, B.res);
  if (flag) {
    rest.maxi = max(rest.maxi, r1);
    rest.mini = min(rest.mini, r1);
    rest.res = max(rest.res, max(B.mini != INF ? B.mini - r1 : 0,
                                 A.mini != INF ? r1 - A.maxi : 0));
  } else {
    if (A.mini != INF && B.mini != INF)
      rest.res = max(rest.res, B.mini - A.maxi);
  }
}
void build(int l = 1, int r = MAXN + 1, int now = 1) {
  if (l == r - 1) {
    node tmp;
    tmp.res = 0;
    tmp.maxi = -INF;
    tmp.mini = INF;
    segtree[now][1] = segtree[now][0] = tmp;
  } else {
    int mid = (l + r) >> 1;
    build(l, mid, now << 1);
    build(mid, r, (now << 1) + 1);
    merge(segtree[now][0], segtree[now << 1][0], segtree[(now << 1) + 1][0],
          nei(init[mid - 1], init[mid]), mid - 1);
    segtree[now][0].c1 = segtree[now][0].c2 = 0;
    segtree[now][1].c1 = segtree[now][1].c2 = 1;
    merge(segtree[now][1], segtree[now << 1][1], segtree[(now << 1) + 1][1],
          nei(Reverse(mid - 1), Reverse(mid)), mid - 1);
  }
}
void go(int a, int b, bool col, int now = 1, int l = 1, int r = MAXN + 1) {
  if (r <= a || l >= b) {
    return;
  }
  if (r <= b && l >= a) {
    swap(segtree[now][0], segtree[now][1]);
    return;
  }
  int mid = (l + r) >> 1;
  go(a, b, segtree[now][col].c1, now << 1, l, mid);
  go(a, b, segtree[now][col].c2, (now << 1) + 1, mid, r);
  merge(segtree[now][col], segtree[now << 1][segtree[now][col].c1],
        segtree[(now << 1) + 1][segtree[now][col].c2],
        nei(RRverse(Reverse(mid - 1)), RRverse(Reverse(mid))), mid - 1);
  merge(segtree[now][col ^ 1], segtree[now << 1][segtree[now][col ^ 1].c1],
        segtree[(now << 1) + 1][segtree[now][col ^ 1].c2],
        nei(Reverse(mid - 1), Reverse(mid)), mid - 1);
}
void change(int l, int r) {
  bit.add(l);
  bit.add(r + 1, -1);
  go(l, r + 1, 0);
}
node ask(int a, int b, bool col, int now = 1, int l = 1, int r = MAXN + 1) {
  if (r <= b && l >= a) {
    return segtree[now][col];
  }
  node rest;
  int mid = (l + r) >> 1;
  if (mid <= a) {
    return ask(a, b, segtree[now][col].c2, (now << 1) + 1, mid, r);
  }
  if (mid - 1 >= b - 1) {
    return ask(a, b, segtree[now][col].c1, now << 1, l, mid);
  }
  merge(rest, ask(a, b, segtree[now][col].c1, now << 1, l, mid),
        ask(a, b, segtree[now][col].c2, (now << 1) + 1, mid, r),
        nei(RRverse(Reverse(mid - 1)), RRverse(Reverse(mid))), mid - 1);
  return rest;
}
int query(int l, int r) {
  node tmp = ask(l, r + 1, 0);
  tmp.res = max(tmp.res, max(tmp.mini != INF ? tmp.mini - l + 1 : 0,
                             tmp.mini != INF ? r - tmp.maxi : 0));
  if (tmp.res == 0) tmp.res = r - l + 1;
  return tmp.res;
}
int main() {
  ios::sync_with_stdio(false);
  memset(init, '>', sizeof(init));
  int n, q;
  cin >> n >> q;
  for (int i = 1; i <= n; ++i) cin >> init[i];
  build();
  while (q--) {
    int l, r;
    cin >> l >> r;
    change(l, r);
    cout << query(l, r) << endl;
  }
  return 0;
}