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 N = 5e5 + 7, INF = 0x3f3f3f3f;
const long long LNF = 0x3f3f3f3f3f3f3f3f;
struct D {
  int l, r, sl, sr, cur, lz, sp[2], lv[2], rv[2], mx[2];
  D() : cur(0) {}
} tr[N << 2];
string s;
inline void pushup(D &cur, D &ls, D &rs, int st) {
  cur.mx[cur.cur ^ st] = max(ls.mx[ls.cur ^ st], rs.mx[rs.cur ^ st]);
  cur.sp[cur.cur ^ st] = 0;
  if (!st) {
    cur.sl = ls.sl;
    cur.sr = rs.sr;
  }
  if ((ls.sr ^ st) && (rs.sl ^ st)) {
    cur.mx[cur.cur ^ st] = max(cur.mx[cur.cur ^ st], ls.rv[1] + rs.lv[1]);
    if (ls.lv[ls.sl ^ st] == -1 && rs.rv[rs.sr ^ st] == -1) {
      cur.sp[cur.cur ^ st] = 1;
      cur.lv[0] = cur.rv[0] = ls.rv[1] + rs.lv[1];
    } else {
      if (ls.lv[ls.sl ^ st] == -1)
        cur.lv[0] = ls.rv[1] + rs.lv[1];
      else
        cur.lv[cur.sl ^ st] = ls.lv[ls.sl ^ st];
      if (rs.rv[rs.sr ^ st] == -1)
        cur.rv[0] = ls.rv[1] + rs.lv[1];
      else
        cur.rv[cur.sr ^ st] = rs.rv[rs.sr ^ st];
    }
  } else if ((ls.sr ^ st) && !(rs.sl ^ st)) {
    if (ls.lv[ls.sl ^ st] == -1 && rs.lv[rs.sl ^ st] == -1) {
      cur.lv[0] = -1;
      cur.rv[1] = ls.rv[1] + rs.rv[1];
    } else if (ls.lv[ls.sl ^ st] == -1 && rs.sp[rs.cur ^ st]) {
      cur.sp[cur.cur ^ st] = 1;
      cur.lv[0] = cur.rv[0] = ls.rv[1] + rs.lv[0];
    } else if (ls.lv[ls.sl ^ st] == -1 && rs.lv[rs.sl ^ st] != -1) {
      cur.lv[0] = ls.rv[1] + rs.lv[0];
      cur.rv[rs.sr ^ st] = rs.rv[rs.sr ^ st];
      cur.mx[cur.cur ^ st] = max(cur.mx[cur.cur ^ st], cur.lv[0]);
    } else if (rs.sp[rs.cur ^ st]) {
      cur.lv[cur.sl ^ st] = ls.lv[ls.sl ^ st];
      cur.rv[cur.sr ^ st] = rs.lv[0] + ls.rv[1];
    } else if (rs.lv[rs.sl ^ st] == -1) {
      cur.rv[1] = ls.rv[1] + rs.rv[1];
      cur.lv[cur.sl ^ st] = ls.lv[ls.sl ^ st];
    } else {
      cur.lv[cur.sl ^ st] = ls.lv[ls.sl ^ st];
      cur.rv[cur.sr ^ st] = rs.rv[rs.sr ^ st];
      cur.mx[cur.cur ^ st] = max(cur.mx[cur.cur ^ st], ls.rv[1] + rs.lv[0]);
    }
  } else if (!(ls.sr ^ st) && (rs.sl ^ st)) {
    if (rs.rv[rs.sr ^ st] == -1 && ls.rv[ls.sr ^ st] == -1) {
      cur.rv[0] = -1;
      cur.lv[1] = ls.lv[1] + rs.lv[1];
    } else if (rs.rv[rs.sr ^ st] == -1 && ls.sp[ls.cur ^ st]) {
      cur.sp[cur.cur ^ st] = 1;
      cur.lv[0] = cur.rv[0] = rs.lv[1] + ls.rv[0];
    } else if (rs.rv[rs.sr ^ st] == -1 && ls.rv[ls.sr ^ st] != -1) {
      cur.rv[0] = rs.lv[1] + ls.rv[0];
      cur.lv[cur.sl ^ st] = ls.lv[ls.sl ^ st];
      cur.mx[cur.cur ^ st] = max(cur.mx[cur.cur ^ st], cur.rv[0]);
    } else if (ls.sp[ls.cur ^ st]) {
      cur.rv[cur.sr ^ st] = rs.rv[rs.sr ^ st];
      cur.lv[cur.sl ^ st] = ls.rv[0] + rs.lv[1];
    } else if (ls.rv[ls.sr ^ st] == -1) {
      cur.lv[1] = rs.lv[1] + ls.lv[1];
      cur.rv[cur.sr ^ st] = rs.rv[rs.sr ^ st];
    } else {
      cur.lv[cur.sl ^ st] = ls.lv[ls.sl ^ st];
      cur.rv[cur.sr ^ st] = rs.rv[rs.sr ^ st];
      cur.mx[cur.cur ^ st] = max(cur.mx[cur.cur ^ st], rs.lv[1] + ls.rv[0]);
    }
  } else {
    cur.lv[cur.sl ^ st] = ls.lv[ls.sl ^ st];
    cur.rv[cur.sr ^ st] = rs.rv[rs.sr ^ st];
  }
  cur.mx[cur.cur ^ st] = max(cur.mx[cur.cur ^ st], cur.lv[cur.sl ^ st]);
  cur.mx[cur.cur ^ st] = max(cur.mx[cur.cur ^ st], cur.rv[cur.sr ^ st]);
}
void print(D temp) {
  cout << "(" << temp.l << "," << temp.r << ")" << endl;
  cout << temp.sl << "-" << temp.sr << endl;
  cout << "sp: " << temp.sp[temp.cur] << endl;
  cout << "mx: " << temp.mx[temp.cur] << endl;
  cout << "lv: " << temp.lv[temp.sl] << " rv: " << temp.rv[temp.sr] << endl;
}
inline void flip(int cur) {
  tr[cur].sl ^= 1;
  tr[cur].sr ^= 1;
  tr[cur].cur ^= 1;
  tr[cur].lz ^= 1;
}
inline void pushdown(int cur) {
  flip(cur << 1);
  flip(cur << 1 | 1);
  tr[cur].lz = 0;
}
void build(int l, int r, int cur) {
  tr[cur].l = l;
  tr[cur].r = r;
  if (l == r) {
    tr[cur].cur = 0;
    tr[cur].mx[0] = tr[cur].mx[1] = 1;
    if (s[l - 1] == '<') {
      tr[cur].sl = 1;
      tr[cur].sr = 0;
      tr[cur].lv[1] = 1;
      tr[cur].lv[0] = -1;
      tr[cur].rv[0] = -1;
      tr[cur].rv[1] = 1;
    } else {
      tr[cur].sl = 0;
      tr[cur].sr = 1;
      tr[cur].lv[0] = -1;
      tr[cur].lv[1] = 1;
      tr[cur].rv[1] = 1;
      tr[cur].rv[0] = -1;
    }
    return;
  }
  int mid = (r + l) >> 1;
  build(l, mid, cur << 1);
  build(mid + 1, r, cur << 1 | 1);
  pushup(tr[cur], tr[cur << 1], tr[cur << 1 | 1], 0);
  pushup(tr[cur], tr[cur << 1], tr[cur << 1 | 1], 1);
}
D query(int l, int r, int cur) {
  if (l <= tr[cur].l && tr[cur].r <= r) {
    flip(cur);
    return tr[cur];
  }
  if (tr[cur].lz) pushdown(cur);
  int mid = (tr[cur].l + tr[cur].r) >> 1;
  D ret;
  if (l <= mid && r > mid) {
    D ld = query(l, r, cur << 1), rd = query(l, r, cur << 1 | 1);
    pushup(ret, ld, rd, 0);
  } else if (l <= mid)
    ret = query(l, r, cur << 1);
  else if (r > mid)
    ret = query(l, r, cur << 1 | 1);
  pushup(tr[cur], tr[cur << 1], tr[cur << 1 | 1], 0);
  pushup(tr[cur], tr[cur << 1], tr[cur << 1 | 1], 1);
  return ret;
}
void show(int cur) {
  if (tr[cur].l != tr[cur].r) {
    show(cur << 1);
    show(cur << 1 | 1);
  }
  print(tr[cur]);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, q, l, r;
  cin >> n >> q >> s;
  build(1, n, 1);
  while (q--) {
    cin >> l >> r;
    D get = query(l, r, 1);
    cout << get.mx[get.cur] << endl;
  }
}