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 = (1 << 19 | 10), size = 1 << 20, mod = 998244353;
template <class o>
void qr(o &x) {
  char c = getchar();
  x = 0;
  int f = 1;
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
  x *= f;
}
template <class o>
void qw(o x) {
  if (x / 10) qw(x / 10);
  putchar(x % 10 + '0');
}
template <class o>
void pr1(o x) {
  if (x < 0) x = -x, putchar('-');
  qw(x);
  putchar(' ');
}
template <class o>
void pr2(o x) {
  if (x < 0) x = -x, putchar('-');
  qw(x);
  puts("");
}
int n, m;
char s[N];
struct node {
  int len[2][2], rev, ans, s;
} e, tr[N * 2][2], t;
node operator*(node a, node b) {
  if (!a.ans) return b;
  node c = a;
  c.s += b.s;
  c.len[1][0] = b.len[1][0];
  c.len[1][1] = b.len[1][1];
  c.rev = 0;
  c.ans = max(c.ans, b.ans);
  int l, r;
  if (!a.len[0][1] && !a.len[1][1])
    l = 1;
  else if (a.len[0][1] && !a.len[1][1])
    l = 2;
  else if (a.len[1][0] && a.len[1][1])
    l = 3;
  else
    l = 4;
  if (!b.len[0][1] && !b.len[1][1])
    r = 1;
  else if (!b.len[0][0] && b.len[1][0])
    r = 2;
  else if (b.len[0][0] && b.len[0][1])
    r = 3;
  else
    r = 4;
  if (l == 1) {
    switch (r) {
      case 1:
        c.len[0][0] = c.len[1][0] = a.len[0][0] + b.len[0][0];
        break;
      case 2:
        c.len[0][1] = b.len[0][1];
        break;
      case 3:
        c.len[0][0] += b.len[0][0];
        c.len[0][1] = b.len[0][1];
        if (b.len[0][0] + b.len[0][1] == b.s)
          c.len[1][0] = c.len[0][0], c.len[1][1] = c.len[0][1];
        break;
      case 4:
        c.len[0][1] = b.len[0][1];
        c.len[1][0] = c.len[0][0];
        c.len[1][1] = c.len[0][1];
        break;
    }
  } else if (l == 2) {
    switch (r) {
      case 1:
        c.len[1][0] += a.len[1][0];
        break;
      case 2:
        c.ans = max(c.ans, a.len[1][0] + b.len[0][1]);
        break;
      case 3:
        c.ans = max(c.ans, a.len[1][0] + b.len[0][0] + b.len[0][1]);
        if (b.len[0][0] + b.len[0][1] == b.s) c.len[1][0] += a.len[1][0];
        break;
      case 4:
        c.len[1][0] = a.len[1][0];
        break;
    }
  } else if (l == 3) {
    switch (r) {
      case 1:
        break;
      case 2:
        c.ans = max(c.ans, a.len[1][0] + a.len[1][1] + b.len[0][1]);
        if (a.len[1][0] + a.len[1][1] == a.s) c.len[0][1] += b.len[0][1];
        break;
      case 3:
        break;
      case 4:
        c.len[1][0] = a.len[1][0];
        c.len[1][1] += a.len[1][1];
        if (a.len[1][0] + a.len[1][1] == a.s)
          c.len[0][0] = c.len[1][0], c.len[0][1] = c.len[1][1];
        break;
    }
  } else {
    switch (r) {
      case 1:
        break;
      case 2:
        c.len[0][1] += b.len[0][1];
        break;
      case 3:
        break;
      case 4:
        c.len[1][1] = (c.len[0][1] += b.len[0][1]);
        break;
    }
  }
  c.ans = max(c.ans, max(c.len[0][0] + c.len[0][1], c.len[1][0] + c.len[1][1]));
  return c;
}
void bt(int x, int l, int r) {
  node &a = tr[x][1], &b = tr[x][0];
  if (l == r) {
    int c = s[l];
    a.len[0][c] = a.len[1][c] = 1;
    a.len[0][c ^ 1] = a.len[1][c ^ 1] = 0;
    a.rev = 0;
    a.ans = a.s = 1;
    b.len[0][c ^ 1] = b.len[1][c ^ 1] = 1;
    b.len[0][c] = b.len[1][c] = 0;
    b.rev = 0;
    b.ans = b.s = 1;
    return;
  }
  int mid = (l + r) / 2;
  bt((x << 1), l, mid);
  bt((x << 1 | 1), mid + 1, r);
  a = tr[(x << 1)][1] * tr[(x << 1 | 1)][1];
  b = tr[(x << 1)][0] * tr[(x << 1 | 1)][0];
}
void fz(int x) {
  swap(tr[x][0], tr[x][1]);
  tr[x][0].rev ^= 1;
  tr[x][1].rev ^= 1;
}
void change(int x, int l, int r, int L, int R) {
  if (L <= l && r <= R) {
    fz(x);
    t = t * tr[x][1];
    return;
  }
  if (tr[x][1].rev)
    fz((x << 1)), fz((x << 1 | 1)), tr[x][1].rev ^= 1, tr[x][0].rev ^= 1;
  int mid = (l + r) / 2;
  if (L <= mid) change((x << 1), l, mid, L, R);
  if (mid < R) change((x << 1 | 1), mid + 1, r, L, R);
  tr[x][1] = tr[(x << 1)][1] * tr[(x << 1 | 1)][1];
  tr[x][0] = tr[(x << 1)][0] * tr[(x << 1 | 1)][0];
}
int main() {
  qr(n);
  qr(m);
  scanf("%s", s + 1);
  for (int i = 1; i <= n; i++) s[i] = (s[i] == '<');
  bt(1, 1, n);
  while (m--) {
    int l, r;
    qr(l);
    qr(r);
    t = e;
    change(1, 1, n, l, r);
    pr2(t.ans);
  }
  return 0;
}