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;
char ch[500005];
bool mk[500005 << 2];
int n, m;
struct node {
  int len, c[2], l[2], r[2], cl[2], cr[2];
  friend node operator+(node x, node y) {
    node z;
    z.len = x.len + y.len;
    for (int i = 0; i <= 1; i++) z.cl[i] = z.cr[i] = 0;
    for (int i = 0; i <= 1; i++) {
      if (x.l[i] == x.len)
        z.l[i] = x.len + y.l[i], z.cl[i] = x.len + y.cl[i];
      else
        z.l[i] = x.l[i];
      if (y.r[i] == y.len)
        z.r[i] = y.len + x.r[i], z.cr[i ^ 1] = y.len + x.cr[i ^ 1];
      else
        z.r[i] = y.r[i];
      if (x.cl[i] == x.len)
        z.cl[i] = max(z.cl[i], x.cl[i] + y.l[i ^ 1]);
      else
        z.cl[i] = max(z.cl[i], x.cl[i]);
      if (y.cr[i] == y.len)
        z.cr[i] = max(z.cr[i], y.cr[i] + x.r[i]);
      else
        z.cr[i] = max(z.cr[i], y.cr[i]);
    }
    int tmp = max(max(z.l[0], z.l[1]), max(z.r[0], z.r[1]));
    z.c[0] = max(max(x.c[0], y.c[0]), max(x.cr[0] + y.l[1], y.cl[0] + x.r[0]));
    z.c[1] = max(max(x.c[1], y.c[1]), max(x.cr[1] + y.l[0], y.cl[1] + x.r[1]));
    return z;
  }
} T[500005 << 2];
void s(node &x) {
  swap(x.c[0], x.c[1]), swap(x.l[0], x.l[1]), swap(x.r[0], x.r[1]),
      swap(x.cl[0], x.cl[1]), swap(x.cr[0], x.cr[1]);
}
void pushdown(int k) {
  mk[k << 1] ^= 1, mk[k << 1 | 1] ^= 1, mk[k] = 0;
  s(T[k << 1]), s(T[k << 1 | 1]);
}
void update(int l, int r, int a, int b, int k) {
  if (a <= l && r <= b) return (void)(s(T[k]), mk[k] ^= 1);
  int mid = (l + r) >> 1;
  if (mk[k]) pushdown(k);
  if (a <= mid) update(l, mid, a, b, k << 1);
  if (b > mid) update(mid + 1, r, a, b, k << 1 | 1);
  T[k] = T[k << 1] + T[k << 1 | 1];
}
node query(int l, int r, int a, int b, int k) {
  if (l == a && r == b) return T[k];
  if (mk[k]) pushdown(k);
  int mid = (l + r) >> 1;
  node tmp;
  if (b <= mid)
    tmp = query(l, mid, a, b, k << 1);
  else if (a > mid)
    tmp = query(mid + 1, r, a, b, k << 1 | 1);
  else
    tmp = query(l, mid, a, mid, k << 1) +
          query(mid + 1, r, mid + 1, b, k << 1 | 1);
  return tmp;
}
void build(int l, int r, int k) {
  if (l == r) {
    T[k].len = 1;
    for (int i = 0; i <= 1; i++) T[k].c[i] = T[k].cl[i] = T[k].cr[i] = 1;
    if (ch[l] == '<')
      T[k].l[0] = T[k].r[0] = 1;
    else
      T[k].l[1] = T[k].r[1] = 1;
    return;
  }
  int mid = (l + r) >> 1;
  build(l, mid, k << 1);
  build(mid + 1, r, k << 1 | 1);
  T[k] = T[k << 1] + T[k << 1 | 1];
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%s", ch + 1);
  build(1, n, 1);
  int x, y;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    update(1, n, x, y, 1);
    printf("%d\n", query(1, n, x, y, 1).c[1]);
  }
}