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;
struct Nude {
  int a1, a2, sz, r1, l1, l2, r2;
  char l, r;
  friend Nude operator+(Nude x, Nude y) {
    if (!x.sz) return y;
    if (!y.sz) return x;
    Nude z;
    z.sz = x.sz + y.sz;
    z.l1 = x.l1, z.r1 = y.r1, z.l2 = x.l2, z.r2 = y.r2;
    z.a1 = max(x.a1, y.a1), z.a2 = max(x.a2, y.a2);
    z.l = x.l, z.r = y.r;
    if (x.r != '<' || y.l != '>') {
      z.a1 = max(z.a1, x.r1 + y.l1);
      if (z.l1 == x.sz) z.l1 += y.l1;
      if (z.r1 == y.sz) z.r1 += x.r1;
    }
    if (x.r != '>' || y.l != '<') {
      z.a2 = max(z.a2, x.r2 + y.l2);
      if (z.l2 == x.sz) z.l2 += y.l2;
      if (z.r2 == y.sz) z.r2 += x.r2;
    }
    return z;
  }
};
Nude seg[N << 2], EMP;
char second[N];
int n, q, lzy[N << 2];
void build(int id = 1, int l = 1, int r = n + 1) {
  if (r - l == 1) {
    seg[id].l = seg[id].r = second[l];
    seg[id].sz = 1;
    seg[id].l1 = seg[id].r1 = seg[id].a1 = seg[id].a2 = seg[id].l2 =
        seg[id].r2 = 1;
    return;
  }
  int mid = (l + r) >> 1;
  build(id << 1, l, mid);
  build(id << 1 | 1, mid, r);
  seg[id] = seg[id << 1] + seg[id << 1 | 1];
}
void shift(int id, int l, int r) {
  if (!lzy[id]) return;
  swap(seg[id].r1, seg[id].r2);
  swap(seg[id].l1, seg[id].l2);
  swap(seg[id].a1, seg[id].a2);
  seg[id].l ^= '>' ^ '<';
  seg[id].r ^= '>' ^ '<';
  if (r - l > 1) {
    lzy[id << 1] ^= 1;
    lzy[id << 1 | 1] ^= 1;
  }
  lzy[id] = 0;
}
void update(int ql, int qr, int id = 1, int l = 1, int r = n + 1) {
  shift(id, l, r);
  if (qr <= l || r <= ql) return;
  if (ql <= l && r <= qr) {
    lzy[id] ^= 1;
    return shift(id, l, r);
  }
  int mid = (l + r) >> 1;
  update(ql, qr, id << 1, l, mid);
  update(ql, qr, id << 1 | 1, mid, r);
  seg[id] = seg[id << 1] + seg[id << 1 | 1];
}
Nude get(int ql, int qr, int id = 1, int l = 1, int r = n + 1) {
  shift(id, l, r);
  if (qr <= l || r <= ql) return EMP;
  if (ql <= l && r <= qr) return seg[id];
  int mid = (l + r) >> 1;
  return get(ql, qr, id << 1, l, mid) + get(ql, qr, id << 1 | 1, mid, r);
}
int main() {
  EMP.sz = 0;
  scanf("%d%d%s", &n, &q, second + 1);
  build();
  while (q--) {
    int l, r;
    scanf("%d%d", &l, &r);
    update(l, r + 1);
    printf("%d\n", get(l, r + 1).a1);
  }
  return 0;
}