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 + 10;
const int mod = 1e9 + 7;
const long long inf = 1e9 + 10;
int n, q;
struct node {
  int sf0 = 0;
  int sf1 = 0;
  int pr0 = 0;
  int pr1 = 0;
  int sfsodi = 0;
  int sfnozli = 0;
  int prsodi = 0;
  int prnozli = 0;
  int nozli = 0;
  int sodi = 0;
  int la = 0;
} seg[maxn << 2];
node upd(node l, node r, int tl, int tr, int tm) {
  node v;
  if (r.sf0 == tr - tm)
    v.sf0 = l.sf0 + tr - tm;
  else
    v.sf0 = r.sf0;
  if (r.sf1 == tr - tm)
    v.sf1 = l.sf1 + tr - tm;
  else
    v.sf1 = r.sf1;
  if (l.pr0 == tm - tl + 1)
    v.pr0 = r.pr0 + tm - tl + 1;
  else
    v.pr0 = l.pr0;
  if (l.pr1 == tm - tl + 1)
    v.pr1 = r.pr1 + tm - tl + 1;
  else
    v.pr1 = l.pr1;
  if (v.sf1 >= tr - tm)
    v.sfsodi = l.sfsodi + tr - tm;
  else {
    if (r.sfsodi >= tr - tm)
      v.sfsodi = l.sf0 + tr - tm;
    else
      v.sfsodi = r.sfsodi;
  }
  if (v.sf0 >= tr - tm)
    v.sfnozli = l.sfnozli + tr - tm;
  else {
    if (r.sfnozli >= tr - tm)
      v.sfnozli = l.sf1 + tr - tm;
    else
      v.sfnozli = r.sfnozli;
  }
  if (v.pr0 >= tm - tl + 1)
    v.prsodi = r.prsodi + tm - tl + 1;
  else {
    if (l.prsodi >= tm - tl + 1)
      v.prsodi = tm - tl + 1 + r.pr1;
    else
      v.prsodi = l.prsodi;
  }
  if (v.pr1 >= tm - tl + 1)
    v.prnozli = r.prnozli + tm - tl + 1;
  else {
    if (l.prnozli >= tm - tl + 1)
      v.prnozli = tm - tl + 1 + r.pr0;
    else
      v.prnozli = l.prnozli;
  }
  v.sodi = max({l.sodi, r.sodi, l.sfsodi + r.pr1, l.sf0 + r.prsodi});
  v.nozli = max({l.nozli, r.nozli, l.sfnozli + r.pr0, l.sf1 + r.prnozli});
  return v;
}
void shift(int id) {
  node v = seg[id];
  if (!v.la) return;
  v.la = 0;
  if (id < (maxn << 1)) {
    (seg[id << 1].la ^= 1);
    (seg[id << 1 | 1].la ^= 1);
  }
  swap(v.pr0, v.pr1);
  swap(v.sf0, v.sf1);
  swap(v.sfnozli, v.sfsodi);
  swap(v.prnozli, v.prsodi);
  swap(v.nozli, v.sodi);
  seg[id] = v;
}
void up(int l, int r, int id = 1, int tl = 1, int tr = n) {
  int tm = (tl + tr) >> 1;
  if (tl == l && tr == r) {
    (seg[id].la ^= 1);
    shift(id);
    return;
  }
  shift(id);
  if (l > r) return;
  up(l, min(tm, r), id << 1, tl, tm);
  up(max(tm + 1, l), r, id << 1 | 1, tm + 1, tr);
  node L = seg[id << 1];
  node R = seg[id << 1 | 1];
  seg[id] = upd(L, R, tl, tr, tm);
}
node qu(int l, int r, int id = 1, int tl = 1, int tr = n) {
  if (l > r) return seg[0];
  shift(id);
  if (tl == l && tr == r) return seg[id];
  int tm = (tl + tr) >> 1;
  node TL = qu(l, min(tm, r), id << 1, tl, tm);
  node TR = qu(max(tm + 1, l), r, id << 1 | 1, tm + 1, tr);
  if (r <= tm) return TL;
  if (l >= tm + 1) return TR;
  return upd(TL, TR, l, r, tm);
}
string s;
void build(int id = 1, int tl = 1, int tr = n) {
  if (tl == tr) {
    int x;
    if (s[tl] == '<')
      x = 1;
    else
      x = 0;
    node v;
    v.pr1 = v.sf1 = x;
    v.pr0 = v.sf0 = 1 - x;
    v.sfnozli = v.sfsodi = v.prnozli = v.prsodi = v.sodi = v.nozli = 1;
    seg[id] = v;
    return;
  }
  int tm = (tl + tr) >> 1;
  build(id << 1, tl, tm);
  build(id << 1 | 1, tm + 1, tr);
  seg[id] = upd(seg[id << 1], seg[id << 1 | 1], tl, tr, tm);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  cin >> s;
  s = "*" + s;
  build();
  while (q--) {
    int l, r;
    cin >> l >> r;
    up(l, r);
    cout << qu(l, r).sodi << "\n";
  }
}