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;
struct node {
  int fl = 0, mx = 0, pl = 0, sl = 0;
  string pf, sf;
};
const int N = 5e5 + 9;
node tr[4 * N][2];
int n, q, lz[4 * N];
string st;
node merge(node x, node y) {
  node r;
  if (x.fl and y.fl) {
    if (x.pf.back() == '<' and y.pf.front() == '>') {
      r.pf = x.pf, r.sf = y.pf;
      r.pl = x.pl, r.sl = y.pl;
      r.mx = max(x.mx, y.mx);
    } else {
      r.pf = x.pf + y.pf;
      r.pl = x.pl + y.pl;
      r.fl = 1;
      r.mx = r.pl;
    }
  } else if (x.fl) {
    r.sf = y.sf;
    r.sl = y.sl;
    if (x.pf.back() == '<' and y.pf.front() == '>') {
      r.pf = x.pf;
      r.pl = x.pl;
      r.mx = max(x.mx, y.mx);
    } else {
      r.pf = x.pf + y.pf;
      r.pl = x.pl + y.pl;
      r.mx = max(r.pl, y.mx);
    }
  } else if (y.fl) {
    r.pf = x.pf;
    r.pl = x.pl;
    if (x.sf.back() == '<' and y.pf.front() == '>') {
      r.sf = y.pf;
      r.sl = y.pl;
      r.mx = max(x.mx, y.mx);
    } else {
      r.sf = x.sf + y.pf;
      r.sl = x.sl + y.pl;
      r.mx = max(r.sl, x.mx);
    }
  } else {
    r.pf = x.pf, r.sf = y.sf;
    r.pl = x.pl, r.sl = y.sl;
    r.mx = max(x.mx, y.mx);
    if (!(x.sf.back() == '<' and y.pf.front() == '>'))
      r.mx = max(r.mx, x.sl + y.pl);
  }
  if (r.pf.size() > 2) {
    string tmp = "";
    tmp += r.pf.front();
    tmp += r.pf.back();
    r.pf = tmp;
  }
  if (r.sf.size() > 2) {
    string tmp = "";
    tmp += r.sf.front();
    tmp += r.sf.back();
    r.sf = tmp;
  }
  return r;
}
void build(int id = 1, int l = 1, int r = n) {
  if (l == r) {
    tr[id][0].mx = 1, tr[id][1].mx = 1;
    tr[id][0].pf = '<', tr[id][1].pf = '>';
    tr[id][0].fl = tr[id][1].fl = 1;
    tr[id][0].pl = tr[id][1].pl = 1;
    if (st[l] == '>') swap(tr[id][0].pf, tr[id][1].pf);
    return;
  }
  int mid = (l + r) / 2;
  build(2 * id, l, mid);
  build(2 * id + 1, mid + 1, r);
  tr[id][0] = merge(tr[2 * id][0], tr[2 * id + 1][0]);
  tr[id][1] = merge(tr[2 * id][1], tr[2 * id + 1][1]);
}
void udt(int x, int y, int id = 1, int l = 1, int r = n) {
  if (l > y or r < x) return;
  if (l >= x and r <= y) {
    lz[id] ^= 1;
    return;
  }
  int mid = (l + r) / 2;
  if (lz[id]) lz[2 * id] ^= 1, lz[2 * id + 1] ^= 1, lz[id] = 0;
  udt(x, y, 2 * id, l, mid);
  udt(x, y, 2 * id + 1, mid + 1, r);
  tr[id][0] = merge(tr[2 * id][lz[2 * id]], tr[2 * id + 1][lz[2 * id + 1]]);
  tr[id][1] =
      merge(tr[2 * id][lz[2 * id] ^ 1], tr[2 * id + 1][lz[2 * id + 1] ^ 1]);
}
node ask(int x, int y, int id = 1, int l = 1, int r = n) {
  if (l >= x and r <= y) return tr[id][lz[id]];
  int mid = (l + r) / 2;
  if (y <= mid) return ask(x, y, 2 * id, l, mid);
  if (x > mid) return ask(x, y, 2 * id + 1, mid + 1, r);
  return merge(ask(x, y, 2 * id, l, mid), ask(x, y, 2 * id + 1, mid + 1, r));
}
int32_t main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n >> q >> st;
  st = '#' + st;
  build();
  while (q--) {
    int l, r;
    cin >> l >> r;
    udt(l, r);
    cout << ask(l, r).mx << '\n';
  }
}