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>
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
using namespace std;
const int MAX = 5e5 + 5;
const long long MAX2 = 11;
const long long MOD = 1000000007;
const long long MOD2 = 1000005329;
const long long INF = 2e18;
const int dr[] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1, 0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 555;
struct segtree {
  bool l, r;
  int rvmx, rvle, rvri;
  int mx, cle, cri;
} tree[1 << 20], ret;
int n, q, a, b;
bool x[MAX], lz[1 << 20];
char c;
inline segtree merge(long long szle, long long szri, segtree le, segtree ri) {
  ret.l = le.l, ret.r = ri.r;
  if (le.r || !ri.l) {
    ret.mx = max(le.cri + ri.cle, max(le.mx, ri.mx));
    ret.cle = (le.cle == szle ? szle + ri.cle : le.cle);
    ret.cri = (ri.cri == szri ? szri + le.cri : ri.cri);
  } else {
    ret.mx = max(le.mx, ri.mx);
    ret.cle = le.cle;
    ret.cri = ri.cri;
  }
  if (!le.r || ri.l) {
    ret.rvmx = max(le.rvri + ri.rvle, max(le.rvmx, ri.rvmx));
    ret.rvle = (le.rvle == szle ? szle + ri.rvle : le.rvle);
    ret.rvri = (ri.rvri == szri ? szri + le.rvri : ri.rvri);
  } else {
    ret.rvmx = max(le.rvmx, ri.rvmx);
    ret.rvle = le.rvle;
    ret.rvri = ri.rvri;
  }
  return ret;
}
inline void f(int &id, int &le, int &ri) {
  tree[id].l ^= 1, tree[id].r ^= 1;
  tree[id].mx ^= tree[id].rvmx ^= tree[id].mx ^= tree[id].rvmx;
  tree[id].cle ^= tree[id].rvle ^= tree[id].cle ^= tree[id].rvle;
  tree[id].cri ^= tree[id].rvri ^= tree[id].cri ^= tree[id].rvri;
  if (le != ri) lz[(id << 1)] ^= 1, lz[((id << 1) | 1)] ^= 1;
  lz[id] = 0;
  return;
}
void build(int id, int le, int ri) {
  if (le == ri) {
    tree[id].l = tree[id].r = x[le];
    tree[id].mx = tree[id].rvmx = tree[id].cle = tree[id].rvle = tree[id].cri =
        tree[id].rvri = 1;
    return;
  }
  int mid = le + ri >> 1;
  build((id << 1), le, mid), build(((id << 1) | 1), mid + 1, ri);
  tree[id] =
      merge(mid - le + 1, ri - mid, tree[(id << 1)], tree[((id << 1) | 1)]);
  return;
}
void upd(int id, int le, int ri) {
  if (lz[id]) f(id, le, ri);
  if (le > b || ri < a) return;
  if (le >= a && ri <= b) {
    f(id, le, ri);
    return;
  }
  int mid = le + ri >> 1;
  upd((id << 1), le, mid), upd(((id << 1) | 1), mid + 1, ri);
  tree[id] =
      merge(mid - le + 1, ri - mid, tree[(id << 1)], tree[((id << 1) | 1)]);
  return;
}
segtree que(int id, int le, int ri) {
  if (lz[id]) f(id, le, ri);
  if (le >= a && ri <= b) return tree[id];
  int mid = le + ri >> 1;
  if (a <= mid && b > mid)
    return merge(mid - max(a, le) + 1, min(b, ri) - mid,
                 que((id << 1), le, mid), que(((id << 1) | 1), mid + 1, ri));
  else if (a <= mid)
    return que((id << 1), le, mid);
  return que(((id << 1) | 1), mid + 1, ri);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  for (int i = 1; i <= n; ++i) cin >> c, x[i] = c == '>';
  build(1, 1, n);
  while (q--) {
    cin >> a >> b;
    upd(1, 1, n);
    cout << que(1, 1, n).mx << '\n';
  }
  return 0;
}