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 next_x[8] = {0, 1, -1, 0, 1, 1, -1, -1};
const int next_y[8] = {1, 0, 0, -1, 1, -1, -1, 1};
const int inf = 1e9 + 5;
const long long linf = 1e18;
const double PI = acos(-1.0);
const int MAXN = 5e5 + 5;
const int N = 1e6 + 5;
void mx(int &f, int v) { f = max(f, v); }
struct info {
  int ans, lans, rans, lseg, rseg, len;
  info operator+(const info &t) const {
    info res;
    res.ans = max({
        ans,
        t.ans,
        rseg + t.lseg,
        rans + t.lseg,
        t.lans + rseg,
    });
    res.lseg = (lseg == len) ? (lseg + t.lseg) : lseg;
    res.rseg = (t.rseg == t.len) ? (rseg + t.rseg) : t.rseg;
    res.lans = lans;
    res.rans = t.rans;
    if (rseg == len && t.lseg == t.len) {
      mx(res.lans, len + t.len);
      mx(res.rans, len + t.len);
    }
    if (rseg == len) {
      mx(res.lans, len + t.lans);
      mx(res.lans, len + t.lseg);
    }
    if (lans == len) mx(res.lans, len + t.lseg);
    if (t.lseg == t.len) {
      mx(res.rans, t.len + rans);
      mx(res.rans, t.len + rseg);
    }
    if (t.rans == t.len) mx(res.rans, t.len + rseg);
    res.len = len + t.len;
    return res;
  }
} s[MAXN * 4], t[MAXN * 4];
bool rev[MAXN * 4];
inline void dorev(int cnt) { rev[cnt] ^= 1, swap(s[cnt], t[cnt]); }
inline void up(int cnt) {
  s[cnt] = s[((cnt << 1))] + s[((cnt << 1 | 1))],
  t[cnt] = t[((cnt << 1))] + t[((cnt << 1 | 1))];
}
inline void down(int cnt) {
  if (rev[cnt]) dorev(((cnt << 1))), dorev(((cnt << 1 | 1))), rev[cnt] = 0;
}
void build(int l, int r, char a[], int cnt) {
  if (l == r) {
    s[cnt] = {0, 0, 0, 1, 0, 1};
    t[cnt] = {0, 0, 0, 0, 1, 1};
    if (a[l] == '<') swap(s[cnt], t[cnt]);
    return;
  }
  build(l, ((l + r) / 2), a, ((cnt << 1)));
  build(((l + r) / 2) + 1, r, a, ((cnt << 1 | 1)));
  up(cnt);
}
info query(int l, int r, int nl, int nr, int cnt) {
  if (l == nl && r == nr) return s[cnt];
  down(cnt);
  if (nr <= ((l + r) / 2)) return query(l, ((l + r) / 2), nl, nr, ((cnt << 1)));
  if (nl > ((l + r) / 2))
    return query(((l + r) / 2) + 1, r, nl, nr, ((cnt << 1 | 1)));
  return query(l, ((l + r) / 2), nl, ((l + r) / 2), ((cnt << 1))) +
         query(((l + r) / 2) + 1, r, ((l + r) / 2) + 1, nr, ((cnt << 1 | 1)));
}
void update(int l, int r, int nl, int nr, int cnt) {
  if (l == nl && r == nr) {
    dorev(cnt);
    return;
  }
  down(cnt);
  if (nr <= ((l + r) / 2))
    update(l, ((l + r) / 2), nl, nr, ((cnt << 1)));
  else if (nl > ((l + r) / 2))
    update(((l + r) / 2) + 1, r, nl, nr, ((cnt << 1 | 1)));
  else
    update(l, ((l + r) / 2), nl, ((l + r) / 2), ((cnt << 1))),
        update(((l + r) / 2) + 1, r, ((l + r) / 2) + 1, nr, ((cnt << 1 | 1)));
  up(cnt);
}
int n, m;
char a[MAXN];
int work() {
  scanf("%d%d", &n, &m);
  scanf("%s", a + 1);
  build(1, n, a, 1);
  while (m--) {
    int l, r;
    scanf("%d%d", &l, &r);
    info res = query(1, n, l, r, 1);
    printf("%d\n", max({res.ans, res.lseg, res.rseg}));
    update(1, n, l, r, 1);
  }
  return 0;
}
int main() {
  work();
  return 0;
}