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 node {
  int l[2], r[2], m[2], lazy;
  void Swap() {
    swap(l[0], l[1]);
    swap(r[0], r[1]);
    swap(m[0], m[1]);
    lazy ^= 1;
  }
} t[N << 2], ans;
node Merge(const node &a, int L, const node &b, int R) {
  node res;
  res.lazy = 0;
  for (int i = 0; i < 2; i++) {
    if (a.l[i] > 0) {
      res.l[i] = a.l[i] + (a.l[i] == L ? max(b.l[i], 0) : 0);
    } else {
      res.l[i] = a.l[i];
      if (a.l[i] == -L && (a.r[i] == L || b.l[i] > 0)) res.l[i] -= abs(b.l[i]);
    }
    if (b.r[i] > 0) {
      res.r[i] = b.r[i] + (b.r[i] == R ? max(a.r[i], 0) : 0);
    } else {
      res.r[i] = b.r[i];
      if (b.r[i] == -R && (b.l[i] == R || a.r[i] > 0)) res.r[i] -= abs(a.r[i]);
    }
    res.m[i] = max(a.m[i], b.m[i]);
    if (a.r[i] > 0 || b.l[i] > 0)
      res.m[i] = max(res.m[i], abs(a.r[i]) + abs(b.l[i]));
  }
  return res;
}
char s[N];
void build(int l, int r, int rt) {
  if (l == r) {
    t[rt].m[0] = t[rt].m[1] = 1;
    if (s[l] == '<') {
      t[rt].l[0] = 1;
      t[rt].r[0] = -1;
    } else {
      t[rt].l[0] = -1;
      t[rt].r[0] = 1;
    }
    t[rt].l[1] = -t[rt].l[0];
    t[rt].r[1] = -t[rt].r[0];
    return;
  }
  int mid = (l + r) >> 1;
  build(l, mid, rt << 1);
  build(mid + 1, r, rt << 1 | 1);
  t[rt] = Merge(t[rt << 1], mid - l + 1, t[rt << 1 | 1], r - mid);
}
void push_down(int rt) {
  if (t[rt].lazy) {
    t[rt << 1].Swap();
    t[rt << 1 | 1].Swap();
    t[rt].lazy ^= 1;
  }
}
int Len;
void update(int x, int y, int l, int r, int rt) {
  if (x <= l && r <= y) {
    t[rt].Swap();
    if (Len > 0)
      ans = Merge(ans, Len, t[rt], r - l + 1);
    else
      ans = t[rt];
    Len += r - l + 1;
    return;
  }
  push_down(rt);
  int mid = (l + r) >> 1;
  if (x <= mid) update(x, y, l, mid, rt << 1);
  if (y > mid) update(x, y, mid + 1, r, rt << 1 | 1);
  t[rt] = Merge(t[rt << 1], mid - l + 1, t[rt << 1 | 1], r - mid);
}
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  scanf("%s", s + 1);
  build(1, n, 1);
  while (q--) {
    int l, r;
    scanf("%d%d", &l, &r);
    Len = 0;
    update(l, r, 1, n, 1);
    printf("%d\n", ans.m[0]);
  }
  return 0;
}