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;
int n, Q, Ans;
int a[500005], L[500005 << 2][4], R[500005 << 2][4], _1[500005 << 2],
    _0[500005 << 2], mx[500005 << 2], c[500005 << 2], bl[4], br[4];
char ch[500005];
void update(int v, int l, int r) {
  int mid = (l + r) >> 1;
  L[v][0] = L[v << 1][0];
  L[v][1] = L[v << 1][1];
  L[v][2] = L[v << 1][2];
  L[v][3] = L[v << 1][3];
  R[v][0] = R[v << 1 | 1][0];
  R[v][1] = R[v << 1 | 1][1];
  R[v][2] = R[v << 1 | 1][2];
  R[v][3] = R[v << 1 | 1][3];
  if (L[v << 1][0] == (mid - l + 1)) {
    L[v][0] += L[v << 1 | 1][0];
    if (L[v << 1 | 1][1]) L[v][2] = L[v << 1][0] + L[v << 1 | 1][1];
    if (L[v << 1 | 1][2]) L[v][2] = L[v << 1][0] + L[v << 1 | 1][2];
  }
  if (L[v << 1][1] == (mid - l + 1)) {
    L[v][1] += L[v << 1 | 1][1];
    if (L[v << 1 | 1][0]) L[v][3] = L[v << 1][1] + L[v << 1 | 1][0];
    if (L[v << 1 | 1][3]) L[v][3] = L[v << 1][1] + L[v << 1 | 1][3];
  }
  if (L[v << 1][2] == (mid - l + 1)) L[v][2] += L[v << 1 | 1][1];
  if (L[v << 1][3] == (mid - l + 1)) L[v][3] += L[v << 1 | 1][0];
  if (R[v << 1 | 1][0] == (r - mid)) {
    R[v][0] += R[v << 1][0];
    if (R[v << 1][1]) R[v][2] = R[v << 1][1] + R[v << 1 | 1][0];
    if (R[v << 1][2]) R[v][2] = R[v << 1][2] + R[v << 1 | 1][0];
  }
  if (R[v << 1 | 1][1] == (r - mid)) {
    R[v][1] += R[v << 1][1];
    if (R[v << 1][0]) R[v][3] = R[v << 1][0] + R[v << 1 | 1][1];
    if (R[v << 1][3]) R[v][3] = R[v << 1][3] + R[v << 1 | 1][1];
  }
  if (R[v << 1 | 1][2] == (r - mid)) R[v][2] += R[v << 1][1];
  if (R[v << 1 | 1][3] == (r - mid)) R[v][3] += R[v << 1][0];
  _1[v] = max(_1[v << 1], _1[v << 1 | 1]);
  _0[v] = max(_0[v << 1], _0[v << 1 | 1]);
  if (R[v << 1][0] && L[v << 1 | 1][1])
    _1[v] = max(_1[v], R[v << 1][0] + L[v << 1 | 1][1]);
  if (R[v << 1][0] && L[v << 1 | 1][2])
    _1[v] = max(_1[v], R[v << 1][0] + L[v << 1 | 1][2]);
  if (R[v << 1][3] && L[v << 1 | 1][1])
    _1[v] = max(_1[v], R[v << 1][3] + L[v << 1 | 1][1]);
  if (R[v << 1][1] && L[v << 1 | 1][0])
    _0[v] = max(_0[v], R[v << 1][1] + L[v << 1 | 1][0]);
  if (R[v << 1][2] && L[v << 1 | 1][0])
    _0[v] = max(_0[v], R[v << 1][2] + L[v << 1 | 1][0]);
  if (R[v << 1][1] && L[v << 1 | 1][3])
    _0[v] = max(_0[v], R[v << 1][1] + L[v << 1 | 1][3]);
  mx[v] = max(_0[v], max(L[v][0], R[v][1]));
}
void build(int v, int l, int r) {
  int i, j, mid = (l + r) >> 1;
  c[v] = 1;
  if (l == r) {
    if (a[l])
      L[v][1] = R[v][1] = 1;
    else
      L[v][0] = R[v][0] = 1;
    mx[v] = 1;
    return;
  }
  build(v << 1, l, mid);
  build(v << 1 | 1, mid + 1, r);
  update(v, l, r);
}
void pushdown(int v) {
  if (c[v] == -1) {
    c[v << 1] *= -1;
    c[v << 1 | 1] *= -1;
    swap(L[v << 1][0], L[v << 1][1]);
    swap(L[v << 1][2], L[v << 1][3]);
    swap(R[v << 1][0], R[v << 1][1]);
    swap(R[v << 1][2], R[v << 1][3]);
    swap(_1[v << 1], _0[v << 1]);
    mx[v << 1] = max(_0[v << 1], max(L[v << 1][0], R[v << 1][1]));
    swap(L[v << 1 | 1][0], L[v << 1 | 1][1]);
    swap(L[v << 1 | 1][2], L[v << 1 | 1][3]);
    swap(R[v << 1 | 1][0], R[v << 1 | 1][1]);
    swap(R[v << 1 | 1][2], R[v << 1 | 1][3]);
    swap(_1[v << 1 | 1], _0[v << 1 | 1]);
    mx[v << 1 | 1] =
        max(_0[v << 1 | 1], max(L[v << 1 | 1][0], R[v << 1 | 1][1]));
    c[v] = 1;
  }
}
void Modify(int v, int l, int r, int x, int y) {
  int i, j, mid = (l + r) >> 1;
  if (x <= l && r <= y) {
    c[v] *= -1;
    swap(L[v][0], L[v][1]);
    swap(L[v][2], L[v][3]);
    swap(R[v][0], R[v][1]);
    swap(R[v][2], R[v][3]);
    swap(_1[v], _0[v]);
    mx[v] = max(_0[v], max(L[v][0], R[v][1]));
    return;
  }
  pushdown(v);
  if (x <= mid) Modify(v << 1, l, mid, x, y);
  if (y > mid) Modify(v << 1 | 1, mid + 1, r, x, y);
  update(v, l, r);
}
void Query(int v, int l, int r, int x, int y) {
  int i, j, mid = (l + r) >> 1;
  int L1[4], R1[4], L2[4], R2[4];
  if (x <= l && r <= y) {
    Ans = max(Ans, mx[v]);
    bl[0] = L[v][0], bl[1] = L[v][1], bl[2] = L[v][2], bl[3] = L[v][3];
    br[0] = R[v][0], br[1] = R[v][1], br[2] = R[v][2], br[3] = R[v][3];
    return;
  }
  pushdown(v);
  if (y <= mid)
    Query(v << 1, l, mid, x, y);
  else if (x > mid)
    Query(v << 1 | 1, mid + 1, r, x, y);
  else {
    Query(v << 1, l, mid, x, y);
    L1[0] = bl[0], L1[1] = bl[1], L1[2] = bl[2], L1[3] = bl[3];
    R1[0] = br[0], R1[1] = br[1], R1[2] = br[2], R1[3] = br[3];
    Query(v << 1 | 1, mid + 1, r, x, y);
    L2[0] = bl[0], L2[1] = bl[1], L2[2] = bl[2], L2[3] = bl[3];
    R2[0] = br[0], R2[1] = br[1], R2[2] = br[2], R2[3] = br[3];
    bl[0] = L1[0], bl[1] = L1[1], bl[2] = L1[2], bl[3] = L1[3];
    br[0] = R2[0], br[1] = R2[1], br[2] = R2[2], br[3] = R2[3];
    if (L1[0] == (mid - max(x, l) + 1)) {
      bl[0] += L2[0];
      if (L2[1]) bl[2] = L1[0] + L2[1];
      if (L2[2]) bl[2] = L1[0] + L2[2];
    }
    if (L1[1] == (mid - max(x, l) + 1)) {
      bl[1] += L2[1];
      if (L2[0]) bl[3] = L1[1] + L2[0];
      if (L2[3]) bl[3] = L1[1] + L2[3];
    }
    if (L1[2] == (mid - max(x, l) + 1)) bl[2] += L2[1];
    if (L1[3] == (mid - max(x, l) + 1)) bl[3] += L2[0];
    if (R2[0] == (min(r, y) - mid)) {
      br[0] += R1[0];
      if (R1[1]) br[2] = R2[0] + R1[1];
      if (R1[2]) br[2] = R2[0] + R1[2];
    }
    if (R2[1] == (min(r, y) - mid)) {
      br[1] += R1[1];
      if (R2[0]) br[3] = R2[1] + R2[0];
      if (R2[3]) br[3] = R2[1] + R2[3];
    }
    if (R2[2] == (min(r, y) - mid)) br[2] += R1[1];
    if (R2[3] == (min(r, y) - mid)) br[3] += R1[0];
    Ans = max(
        Ans,
        max(bl[0], max(br[1], max(R1[1] + max(L2[0], L2[3]), L2[0] + R1[2]))));
  }
}
int main() {
  scanf("%d%d", &n, &Q);
  scanf("%s", ch + 1);
  for (int i = 1; i <= n; i++) {
    if (ch[i] == '>')
      a[i] = 1;
    else
      a[i] = 0;
  }
  build(1, 1, n);
  while (Q--) {
    Ans = 0;
    int l, r;
    scanf("%d%d", &l, &r);
    Modify(1, 1, n, l, r);
    Query(1, 1, n, l, r);
    printf("%d\n", Ans);
  }
}