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 mxN = 5e5;
int n, q;
string s;
struct node {
  int len, pre[2], suf[2], ans[2], pre2[2], suf2[2];
} st[1 << 20];
bool lz[1 << 20];
node cmb(node l, node r) {
  node a;
  a.len = l.len + r.len;
  for (int k : {0, 1}) {
    a.pre[k] = l.pre[k] == l.len ? l.len + r.pre[k] : l.pre[k];
    a.suf[k] = r.suf[k] == r.len ? r.len + l.suf[k] : r.suf[k];
    a.ans[k] =
        max({l.ans[k], r.ans[k], l.suf2[k] + r.pre[k], l.suf[k] + r.pre2[k]});
  }
  for (int k : {0, 1}) {
    a.pre2[k] = l.suf[k] == l.len
                    ? l.len + r.pre2[k]
                    : (l.pre2[k] == l.len ? l.len + r.pre[k] : l.pre2[k]);
    a.suf2[k] = r.pre[k] == r.len
                    ? r.len + l.suf2[k]
                    : (r.suf2[k] == r.len ? r.len + l.suf[k] : r.suf2[k]);
  }
  return a;
}
void bld(int i = 1, int l2 = 0, int r2 = n - 1) {
  if (l2 == r2) {
    st[i].len = 1;
    int k = s[l2] != '<';
    st[i].pre[k] = 1;
    st[i].suf[k ^ 1] = 1;
    for (int j : {0, 1}) st[i].pre2[j] = st[i].suf2[j] = st[i].ans[j] = 1;
    return;
  }
  int m2 = (l2 + r2) / 2;
  bld(2 * i, l2, m2);
  bld(2 * i + 1, m2 + 1, r2);
  st[i] = cmb(st[2 * i], st[2 * i + 1]);
}
void app(int i, bool x) {
  if (x) {
    swap(st[i].pre[0], st[i].pre[1]);
    swap(st[i].suf[0], st[i].suf[1]);
    swap(st[i].pre2[0], st[i].pre2[1]);
    swap(st[i].suf2[0], st[i].suf2[1]);
    swap(st[i].ans[0], st[i].ans[1]);
  }
  lz[i] ^= x;
}
void psh(int i) {
  app(2 * i, lz[i]);
  app(2 * i + 1, lz[i]);
  lz[i] = 0;
}
void upd(int l1, int r1, int i = 1, int l2 = 0, int r2 = n - 1) {
  if (l1 <= l2 && r2 <= r1) {
    app(i, 1);
    return;
  }
  int m2 = (l2 + r2) / 2;
  psh(i);
  if (l1 <= m2) upd(l1, r1, 2 * i, l2, m2);
  if (m2 < r1) upd(l1, r1, 2 * i + 1, m2 + 1, r2);
  st[i] = cmb(st[2 * i], st[2 * i + 1]);
}
node qry(int l1, int r1, int i = 1, int l2 = 0, int r2 = n - 1) {
  if (l1 <= l2 && r2 <= r1) return st[i];
  int m2 = (l2 + r2) / 2;
  psh(i);
  if (r1 <= m2) return qry(l1, r1, 2 * i, l2, m2);
  if (m2 < l1) return qry(l1, r1, 2 * i + 1, m2 + 1, r2);
  return cmb(qry(l1, r1, 2 * i, l2, m2), qry(l1, r1, 2 * i + 1, m2 + 1, r2));
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> q;
  cin >> s;
  bld();
  while (q--) {
    int l, r;
    cin >> l >> r, --l, --r;
    upd(l, r);
    cout << qry(l, r).ans[0] << "\n";
  }
}