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 + 5;
struct node {
  pair<bool, int> l[2], r[2];
  int mx[2], le, ri;
  bool flip;
} em;
vector<node> d(4 * N);
string second;
node merge(node a, node b) {
  if (a.mx[0] == -1) return b;
  if (b.mx[0] == -1) return a;
  node sol;
  for (int i = 0; i < 2; i++) {
    if (a.ri - a.le + 1 == a.l[i].second) {
      if (a.r[i].first == 1 || b.l[i].first == 1)
        sol.l[i] = {a.l[i].first, a.l[i].second + b.l[i].second};
      else
        sol.l[i] = a.l[i];
    } else
      sol.l[i] = a.l[i];
    if (b.ri - b.le + 1 == b.r[i].second) {
      if (b.l[i].first == 1 || a.r[i].first == 1)
        sol.r[i] = {b.r[i].first, b.r[i].second + a.r[i].second};
      else
        sol.r[i] = b.r[i];
    } else
      sol.r[i] = b.r[i];
    sol.mx[i] = max({a.mx[i], b.mx[i], sol.l[i].second, sol.r[i].second});
    if (a.r[i].first || b.l[i].first)
      sol.mx[i] = max(sol.mx[i], a.r[i].second + b.l[i].second);
  }
  sol.flip = 0;
  sol.le = a.le;
  sol.ri = b.ri;
  return sol;
}
void sw(int i) {
  swap(d[i].l[0], d[i].l[1]);
  swap(d[i].r[0], d[i].r[1]);
  swap(d[i].mx[0], d[i].mx[1]);
  d[i].flip ^= 1;
}
void prop(int i) {
  if (d[i].flip) {
    d[i].flip = 0;
    sw(2 * i);
    sw(2 * i + 1);
  }
}
void build(int l = 0, int r = N - 1, int i = 1) {
  if (l == r) {
    d[i].le = d[i].ri = l;
    if (second[l] == '<') {
      d[i].mx[0] = d[i].mx[1] = 1;
      d[i].l[0] = {1, 1};
      d[i].r[0] = {0, 1};
      d[i].l[1] = {0, 1};
      d[i].r[1] = {1, 1};
      d[i].flip = 0;
    } else {
      d[i].mx[0] = d[i].mx[1] = 1;
      d[i].l[0] = {0, 1};
      d[i].r[0] = {1, 1};
      d[i].l[1] = {1, 1};
      d[i].r[1] = {0, 1};
      d[i].flip = 0;
    }
    return;
  }
  int m = (l + r) >> 1;
  build(l, m, 2 * i);
  build(m + 1, r, 2 * i + 1);
  d[i] = merge(d[2 * i], d[2 * i + 1]);
}
node getFlip(int qs, int qe, int l = 0, int r = N - 1, int i = 1) {
  if (qs > r || qe < l) return em;
  if (qs <= l && qe >= r) {
    sw(i);
    return d[i];
  }
  int m = (l + r) >> 1;
  prop(i);
  node lft = getFlip(qs, qe, l, m, 2 * i),
       rght = getFlip(qs, qe, m + 1, r, 2 * i + 1);
  node ret = merge(lft, rght);
  d[i] = merge(d[2 * i], d[2 * i + 1]);
  return ret;
}
int main() {
  em.mx[0] = -1;
  int n, q;
  scanf("%i %i", &n, &q);
  cin >> second;
  while (second.size() < N) second += '>';
  build();
  for (int i = 0; i < q; i++) {
    int l, r;
    scanf("%i %i", &l, &r);
    printf("%i\n", getFlip(l - 1, r - 1).mx[0]);
  }
  return 0;
}