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;
char s[N];
struct Node {
  int lR, lL, rL, rR, maxn, tmaxn, lz, sz, lmaxn, rmaxn, ltmaxn, rtmaxn;
} t[N * 4];
Node combine(Node a, Node b) {
  Node x;
  x.lR = a.lR;
  if (x.lR == a.sz) x.lR += b.lR;
  x.lL = a.lL;
  if (x.lL == a.sz) x.lL += b.lL;
  x.rR = b.rR;
  if (x.rR == b.sz) x.rR += a.rR;
  x.rL = b.rL;
  if (x.rL == b.sz) x.rL += a.rL;
  x.maxn = max(max(a.maxn, b.maxn), max(a.rmaxn + b.lL, a.rR + b.lmaxn));
  x.tmaxn = max(max(a.tmaxn, b.tmaxn), max(a.rtmaxn + b.lR, a.rL + b.ltmaxn));
  x.lmaxn = a.lmaxn;
  if (x.lmaxn == a.sz) x.lmaxn += b.lL;
  if (a.lR == a.sz) x.lmaxn = max(x.lmaxn, a.sz + b.lmaxn);
  x.ltmaxn = a.ltmaxn;
  if (x.ltmaxn == a.sz) x.ltmaxn += b.lR;
  if (a.lL == a.sz) x.ltmaxn = max(x.ltmaxn, a.sz + b.ltmaxn);
  x.rmaxn = b.rmaxn;
  if (x.rmaxn == b.sz) x.rmaxn += a.rR;
  if (b.rL == b.sz) x.rmaxn = max(x.rmaxn, b.sz + a.rmaxn);
  x.rtmaxn = b.rtmaxn;
  if (x.rtmaxn == b.sz) x.rtmaxn += a.rL;
  if (b.rR == b.sz) x.rtmaxn = max(x.rtmaxn, b.sz + a.rtmaxn);
  x.sz = a.sz + b.sz, x.lz = 0;
  return x;
}
void build(int idx, int l, int r) {
  if (l == r) {
    t[idx].rR = t[idx].lR = (s[l] == '>');
    t[idx].rL = t[idx].lL = (s[l] == '<');
    t[idx].maxn = t[idx].tmaxn = t[idx].lmaxn = t[idx].rmaxn = t[idx].ltmaxn =
        t[idx].rtmaxn = 1;
    t[idx].sz = 1, t[idx].lz = 0;
    return;
  }
  int mid = (l + r) >> 1;
  build(idx << 1, l, mid), build(idx << 1 | 1, mid + 1, r);
  t[idx] = combine(t[idx << 1], t[idx << 1 | 1]);
}
void rev(int idx) {
  t[idx].lz ^= 1;
  swap(t[idx].lL, t[idx].lR), swap(t[idx].rR, t[idx].rL),
      swap(t[idx].maxn, t[idx].tmaxn);
  swap(t[idx].lmaxn, t[idx].ltmaxn), swap(t[idx].rmaxn, t[idx].rtmaxn);
}
void pushdown(int idx) {
  if (!t[idx].lz) return;
  t[idx].lz = 0, rev(idx << 1), rev(idx << 1 | 1);
}
void change(int idx, int l, int r, int a, int b) {
  if (a <= l && b >= r) {
    rev(idx);
    return;
  }
  pushdown(idx);
  int mid = (l + r) >> 1;
  if (b <= mid)
    change(idx << 1, l, mid, a, b);
  else if (a > mid)
    change(idx << 1 | 1, mid + 1, r, a, b);
  else
    change(idx << 1, l, mid, a, b), change(idx << 1 | 1, mid + 1, r, a, b);
  t[idx] = combine(t[idx << 1], t[idx << 1 | 1]);
}
Node query(int idx, int l, int r, int a, int b) {
  if (a <= l && b >= r) return t[idx];
  pushdown(idx);
  int mid = (l + r) >> 1;
  if (b <= mid)
    return query(idx << 1, l, mid, a, b);
  else if (a > mid)
    return query(idx << 1 | 1, mid + 1, r, a, b);
  else
    return combine(query(idx << 1, l, mid, a, b),
                   query(idx << 1 | 1, mid + 1, r, a, b));
}
int main() {
  int n, q;
  scanf("%d%d%s", &n, &q, s + 1);
  build(1, 1, n);
  for (int i = 1; i <= q; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    change(1, 1, n, l, r);
    printf("%d\n", query(1, 1, n, l, r).maxn);
  }
  return 0;
}