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 maxn = 1e6 + 100;
const int mod = 1e9 + 7;
const int inf = 1e9;
struct node {
  int mx, sl, sr, ml, mr, sz;
  node() {
    sz = 0;
    return;
  }
};
int n, q;
node seg[2][maxn * 4];
node ndnl = node();
bool lz[maxn * 4];
string st;
node mrg(node l, node r) {
  node a;
  if (l.sz == 0) return r;
  if (r.sz == 0) return l;
  a.sz = l.sz + r.sz;
  a.mx = max(max(l.mx, r.mx), max(l.mr + r.sl, l.sr + r.ml));
  a.sr = r.sr;
  if (r.sr == r.sz) a.sr += l.sr;
  a.sl = l.sl;
  if (l.sl == l.sz) a.sl += r.sl;
  a.ml = l.ml;
  if (l.ml == l.sz) a.ml += r.sl;
  if (l.sr == l.sz) a.ml = max(a.ml, l.sr + r.ml);
  a.mr = r.mr;
  if (r.mr == r.sz) a.mr += l.sr;
  if (r.sl == r.sz) a.mr = max(a.mr, r.sl + l.mr);
  return a;
}
void bld(int id, int s, int e) {
  if (e - s == 1) {
    seg[0][id].sz = 1;
    seg[0][id].mx = 1;
    seg[0][id].ml = 1;
    seg[0][id].mr = 1;
    seg[1][id].sz = 1;
    seg[1][id].mx = 1;
    seg[1][id].ml = 1;
    seg[1][id].mr = 1;
    if (st[s] == '<') {
      seg[0][id].sl = 1;
      seg[0][id].sr = 0;
      seg[1][id].sl = 0;
      seg[1][id].sr = 1;
    } else {
      seg[1][id].sl = 1;
      seg[1][id].sr = 0;
      seg[0][id].sl = 0;
      seg[0][id].sr = 1;
    }
    return;
  }
  int mid = (s + e) / 2;
  bld(id * 2, s, mid);
  bld(id * 2 + 1, mid, e);
  seg[0][id] = mrg(seg[0][id * 2], seg[0][id * 2 + 1]);
  seg[1][id] = mrg(seg[1][id * 2], seg[1][id * 2 + 1]);
  return;
}
void upd(int id, int s, int e, int l, int r) {
  if (r <= s || e <= l) return;
  if (l <= s && e <= r) {
    swap(seg[0][id], seg[1][id]);
    lz[id] = !lz[id];
    return;
  }
  int mid = (s + e) / 2;
  if (lz[id]) {
    swap(seg[0][id * 2], seg[1][id * 2]);
    lz[id * 2] = !lz[id * 2];
    swap(seg[0][id * 2 + 1], seg[1][id * 2 + 1]);
    lz[id * 2 + 1] = !lz[id * 2 + 1];
    lz[id] = 0;
  }
  upd(id * 2, s, mid, l, r);
  upd(id * 2 + 1, mid, e, l, r);
  seg[0][id] = mrg(seg[0][id * 2], seg[0][id * 2 + 1]);
  seg[1][id] = mrg(seg[1][id * 2], seg[1][id * 2 + 1]);
  return;
}
node get(int id, int s, int e, int l, int r) {
  if (r <= s || e <= l) {
    return ndnl;
  }
  if (l <= s && e <= r) {
    return seg[0][id];
  }
  int mid = (s + e) / 2;
  if (lz[id]) {
    swap(seg[0][id * 2], seg[1][id * 2]);
    lz[id * 2] = !lz[id * 2];
    swap(seg[0][id * 2 + 1], seg[1][id * 2 + 1]);
    lz[id * 2 + 1] = !lz[id * 2 + 1];
    lz[id] = 0;
  }
  node p = mrg(get(id * 2, s, mid, l, r), get(id * 2 + 1, mid, e, l, r));
  return p;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int l, r;
  cin >> n >> q >> st;
  bld(1, 0, n);
  for (int i = 0; i < q; i++) {
    cin >> l >> r;
    upd(1, 0, n, l - 1, r);
    cout << get(1, 0, n, l - 1, r).mx << '\n';
  }
  return 0;
}