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, sqd[500010], decl[1010], decr[1010], decm[1010], declrev[1010],
    decrrev[1010], decmrev[1010], decd[1010], l, r, com[1010], ter[1010];
char c;
void make_cam(int cam) {
  int ld = 500 * cam, lrev = 500 * cam;
  com[cam] = sqd[500 * cam];
  ter[cam] = sqd[min(n - 1, 500 * (cam + 1) - 1)];
  decm[cam] = 0;
  decmrev[cam] = 0;
  decl[cam] = n;
  declrev[cam] = n;
  for (int j = 500 * cam + 1; j < n && j < 500 * (cam + 1); j++) {
    if (sqd[j] == 1 && sqd[j - 1] == -1) {
      decl[cam] = min(decl[cam], j);
      decr[cam] = j;
      decm[cam] = max(decm[cam], j - ld);
      ld = j;
    }
    if (sqd[j] == -1 && sqd[j - 1] == 1) {
      declrev[cam] = min(declrev[cam], j);
      decrrev[cam] = j;
      decmrev[cam] = max(decmrev[cam], j - lrev);
      lrev = j;
    }
  }
  decm[cam] = max(decm[cam], min(n, 500 * (cam + 1)) - ld);
  decmrev[cam] = max(decmrev[cam], min(n, 500 * (cam + 1)) - lrev);
}
void rev(int in, int fi) {
  if (in / 500 == (fi - 1) / 500) {
    if (in % 500 == 0 && fi % 500 == 0)
      decd[in / 500] *= -1;
    else {
      for (int i = in; i < fi; i++) sqd[i] *= -1;
      make_cam(in / 500);
    }
  } else {
    rev(in, 500 * (in / 500) + 500);
    rev(500 * (in / 500) + 500, fi);
  }
}
int best(int in, int fi) {
  int resp = 0, ld = in, rd;
  for (rd = ld + 1; rd % 500 && rd < fi; rd++) {
    if (sqd[rd] * decd[rd / 500] == 1 &&
        sqd[rd - 1] * decd[(rd - 1) / 500] == -1) {
      resp = max(resp, rd - ld);
      ld = rd;
    }
  }
  for (int i = in / 500 + 1; i < (fi - 1) / 500; i++) {
    if (com[i] * decd[i] == 1 && ter[i - 1] * decd[i - 1] == -1) {
      resp = max(resp, 500 * i - ld);
      ld = 500 * i;
    }
    if (decd[i] == 1) {
      resp = max(resp, decm[i]);
      if (decl[i] < n) {
        resp = max(resp, decl[i] - ld);
        ld = decr[i];
      }
    } else {
      resp = max(resp, decmrev[i]);
      if (declrev[i] < n) {
        resp = max(resp, declrev[i] - ld);
        ld = decrrev[i];
      }
    }
    rd += 500;
  }
  while (rd < fi) {
    if (sqd[rd] * decd[rd / 500] == 1 &&
        sqd[rd - 1] * decd[(rd - 1) / 500] == -1) {
      resp = max(resp, rd - ld);
      ld = rd;
    }
    rd++;
  }
  resp = max(resp, fi - ld);
  return resp;
}
int main() {
  scanf("%d %d", &n, &q);
  for (int i = 0; i < n; i++) {
    scanf(" %c", &c);
    if (c == '>')
      sqd[i] = 1;
    else
      sqd[i] = -1;
  }
  for (int i = 0; 500 * i < n; i++) {
    make_cam(i);
    decd[i] = 1;
  }
  for (int i = 0; i < q; i++) {
    scanf("%d %d", &l, &r);
    l--;
    rev(l, r);
    printf("%d\n", best(l, r));
  }
  return 0;
}