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 + 20;
struct node {
  int sz;
  int res1, l1, r1;
  int res2, l2, r2;
  char cl, cr;
  bool lazy;
  node() {
    sz = 0;
    res1 = l1 = r1 = 0;
    res2 = l2 = r2 = 0;
    cl = cr = 0;
    lazy = 0;
  }
} seg[N << 2];
int n, q;
string str;
inline node merge(node a, node b) {
  if (!a.sz) return b;
  if (!b.sz) return a;
  node res;
  res.sz = a.sz + b.sz;
  res.res1 = max(a.res1, b.res1);
  res.l1 = a.l1;
  res.r1 = b.r1;
  if (!(a.cr == '<' && b.cl == '>')) {
    res.res1 = max(res.res1, a.r1 + b.l1);
    if (res.r1 == b.sz) res.r1 += a.r1;
    if (res.l1 == a.sz) res.l1 += b.l1;
  }
  res.res2 = max(a.res2, b.res2);
  res.l2 = a.l2;
  res.r2 = b.r2;
  if (!(a.cr == '>' && b.cl == '<')) {
    res.res2 = max(res.res2, a.r2 + b.l2);
    if (res.r2 == b.sz) res.r2 += a.r2;
    if (res.l2 == a.sz) res.l2 += b.l2;
  }
  res.cl = a.cl, res.cr = b.cr;
  return res;
}
void build(int v = 1, int s = 0, int e = n) {
  if (e - s == 1) {
    seg[v].sz = 1;
    seg[v].res1 = seg[v].l1 = seg[v].r1 = 1;
    seg[v].res2 = seg[v].l2 = seg[v].r2 = 1;
    seg[v].cl = seg[v].cr = str[s];
    return;
  }
  build((v << 1), s, ((s + e) >> 1));
  build(((v << 1) ^ 1), ((s + e) >> 1), e);
  seg[v] = merge(seg[(v << 1)], seg[((v << 1) ^ 1)]);
}
inline void flip(int v) {
  swap(seg[v].res1, seg[v].res2);
  swap(seg[v].l1, seg[v].l2);
  swap(seg[v].r1, seg[v].r2);
  seg[v].cl = '<' + '>' - seg[v].cl;
  seg[v].cr = '<' + '>' - seg[v].cr;
  seg[v].lazy ^= 1;
}
inline void shift(int v) {
  if (!seg[v].lazy) return;
  flip((v << 1));
  flip(((v << 1) ^ 1));
  seg[v] = merge(seg[(v << 1)], seg[((v << 1) ^ 1)]);
  seg[v].lazy = 0;
}
void change(int l, int r, int v = 1, int s = 0, int e = n) {
  if (r <= s || e <= l) return;
  if (l <= s && e <= r) {
    flip(v);
    return;
  }
  shift(v);
  change(l, r, (v << 1), s, ((s + e) >> 1));
  change(l, r, ((v << 1) ^ 1), ((s + e) >> 1), e);
  seg[v] = merge(seg[(v << 1)], seg[((v << 1) ^ 1)]);
}
node get(int l, int r, int v = 1, int s = 0, int e = n) {
  if (r <= s || e <= l) return node();
  if (l <= s && e <= r) return seg[v];
  shift(v);
  node a = get(l, r, (v << 1), s, ((s + e) >> 1));
  node b = get(l, r, ((v << 1) ^ 1), ((s + e) >> 1), e);
  return merge(a, b);
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> q;
  cin >> str;
  build();
  while (q--) {
    int l, r;
    cin >> l >> r;
    l--;
    change(l, r);
    cout << get(l, r).res1 << '\n';
  }
}