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 INF = 1e9 + 7, N = 5e5 + 7;
int n, q;
string s;
struct node {
  int ans, lans, rans, ltype, rtype, len;
  node() { ans = lans = rans = ltype = rtype = len = 0; }
  node(int type) {
    ltype = rtype = type;
    ans = lans = rans = len = 1;
  }
} a[N * 4], b[N * 4];
bool lz[N * 4];
node operator+(const node a, const node b) {
  if (a.len == 0) return b;
  if (b.len == 0) return a;
  node ret;
  ret.len = a.len + b.len;
  ret.ltype = a.ltype, ret.rtype = b.rtype;
  ret.ans = max(a.ans, b.ans);
  ret.lans = a.lans, ret.rans = b.rans;
  if (!(a.rtype == 0 && b.ltype == 1)) {
    ret.ans = max(ret.ans, a.rans + b.lans);
    if (a.lans == a.len) ret.lans = a.lans + b.lans;
    if (b.rans == b.len) ret.rans = a.rans + b.rans;
  }
  return ret;
}
void apply(int v) {
  lz[v] ^= 1;
  swap(a[v], b[v]);
}
void push(int v) {
  if (lz[v]) {
    apply(v * 2);
    apply(v * 2 + 1);
    lz[v] = 0;
  }
}
void bld(int v = 1, int tl = 0, int tr = n) {
  if (tr - tl == 1) {
    if (s[tl] == '<')
      a[v] = node(0), b[v] = node(1);
    else
      a[v] = node(1), b[v] = node(0);
    return;
  }
  int tm = (tl + tr) / 2;
  bld(v * 2, tl, tm);
  bld(v * 2 + 1, tm, tr);
  a[v] = a[v * 2] + a[v * 2 + 1];
  b[v] = b[v * 2] + b[v * 2 + 1];
}
void upd(int l, int r, int v = 1, int tl = 0, int tr = n) {
  if (l >= r) return;
  if (l == tl && r == tr) {
    apply(v);
    return;
  }
  push(v);
  int tm = (tl + tr) / 2;
  upd(l, min(tm, r), v * 2, tl, tm);
  upd(max(tm, l), r, v * 2 + 1, tm, tr);
  a[v] = a[v * 2] + a[v * 2 + 1];
  b[v] = b[v * 2] + b[v * 2 + 1];
}
node qry(int l, int r, int v = 1, int tl = 0, int tr = n) {
  if (l >= r) return node();
  if (l == tl && r == tr) return a[v];
  push(v);
  int tm = (tl + tr) / 2;
  return qry(l, min(r, tm), v * 2, tl, tm) +
         qry(max(l, tm), r, v * 2 + 1, tm, tr);
}
signed main() {
  std::ios::sync_with_stdio(0);
  std::cin.tie(0);
  ;
  cin >> n >> q >> s;
  bld();
  while (q--) {
    int l, r;
    cin >> l >> r;
    l--;
    upd(l, r);
    cout << qry(l, r).ans << endl;
  }
}