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;
int n, a[500010], m, k, q;
char s[500010];
struct tree {
  int l[2], l10, l01;
  int r[2], r10, r01;
  int mx10, mx01;
  int rev, len;
  inline void init() {
    len = 0,
    l[0] = l[1] = l10 = l01 = r[0] = r[1] = r10 = r01 = mx10 = mx01 = rev = 0;
  }
  inline void down() {
    rev ^= 1;
    swap(l[0], l[1]), swap(l01, l10);
    swap(r[0], r[1]), swap(r01, r10);
    swap(mx10, mx01);
  }
} T[(1 << 20) + 1];
inline void Mx(int &a, int b) {
  if (b > a) a = b;
}
inline tree up(tree l, tree r) {
  if (l.rev == -1) return r;
  tree k;
  k.rev = 0, k.len = l.len + r.len;
  k.l[0] = l.l[0], k.l[1] = l.l[1];
  int lenl = l.len, lenr = r.len;
  if (l.l[0] == lenl) k.l[0] = l.l[0] + r.l[0];
  if (l.l[1] == lenl) k.l[1] = l.l[1] + r.l[1];
  k.l10 = l.l10, k.l01 = l.l01;
  if (l.l10 == lenl) k.l10 = l.l10 + r.l[0];
  if (l.l[1] == lenl) {
    if (r.l[0]) Mx(k.l10, lenl + r.l[0]);
    if (r.l10) Mx(k.l10, lenl + r.l10);
  }
  if (l.l01 == lenl) k.l01 = lenl + r.l[1];
  if (l.l[0] == lenl) {
    if (r.l[1]) Mx(k.l01, lenl + r.l[1]);
    if (r.l01) Mx(k.l01, lenl + r.l01);
  }
  k.r[0] = r.r[0], k.r[1] = r.r[1];
  if (r.r[0] == lenr) k.r[0] = r.r[0] + l.r[0];
  if (r.r[1] == lenr) k.r[1] = r.r[1] + l.r[1];
  k.r10 = r.r10, k.r01 = r.r01;
  if (r.r10 == lenr) k.r10 = r.r10 + l.r[1];
  if (r.r[0] == lenr) {
    if (l.r[1]) Mx(k.r10, lenr + l.r[1]);
    if (l.r10) Mx(k.r10, lenr + l.r10);
  }
  if (r.r01 == lenr) k.r01 = lenr + l.r[0];
  if (r.r[1] == lenr) {
    if (l.r[0]) Mx(k.r01, lenr + l.r[0]);
    if (l.r01) Mx(k.r01, lenr + l.r01);
  }
  k.mx01 = max({l.mx01, r.mx01, k.l01, k.r01});
  if (l.r[0] && r.l[1]) Mx(k.mx01, l.r[0] + r.l[1]);
  if (l.r01 && r.l[1]) Mx(k.mx01, l.r01 + r.l[1]);
  if (l.r[0] && r.l01) Mx(k.mx01, l.r[0] + r.l01);
  k.mx10 = max({l.mx10, r.mx10, k.l10, k.r10});
  if (l.r[1] && r.l[0]) Mx(k.mx10, l.r[1] + r.l[0]);
  if (l.r10 && r.l[0]) Mx(k.mx10, l.r10 + r.l[0]);
  if (l.r[1] && r.l10) Mx(k.mx10, l.r[1] + r.l10);
  return k;
}
void build(int k, int l, int r) {
  T[k].len = r - l + 1, T[k].rev = 0;
  if (l == r) {
    T[k].l[a[l]] = T[k].r[a[l]] = 1;
    return;
  }
  int m = l + r >> 1;
  build(k << 1, l, m), build(k << 1 | 1, m + 1, r);
  T[k] = up(T[k << 1], T[k << 1 | 1]);
}
inline void down(int k) {
  T[k << 1].down(), T[k << 1 | 1].down();
  T[k].rev = 0;
}
tree res;
void rever(int k, int l, int r, int L, int R) {
  if (l >= L && r <= R) {
    T[k].down();
    return;
  }
  if (T[k].rev) down(k);
  int m = l + r >> 1;
  if (L <= m) rever(k << 1, l, m, L, R);
  if (R > m) rever(k << 1 | 1, m + 1, r, L, R);
  T[k] = up(T[k << 1], T[k << 1 | 1]);
}
void ask(int k, int l, int r, int L, int R) {
  if (l >= L && r <= R) {
    res = up(res, T[k]);
    return;
  }
  if (T[k].rev) down(k);
  int m = l + r >> 1;
  if (L <= m) ask(k << 1, l, m, L, R);
  if (R > m) ask(k << 1 | 1, m + 1, r, L, R);
  T[k] = up(T[k << 1], T[k << 1 | 1]);
}
inline void solve() {
  scanf("%d%d", &n, &q);
  scanf("%s", s + 1);
  for (auto i = (1); i <= (n); ++i) a[i] = (s[i] == '>');
  build(1, 1, n);
  while (q--) {
    int l, r;
    scanf("%d%d", &l, &r);
    rever(1, 1, n, l, r);
    res.init(), res.rev = -1;
    ask(1, 1, n, l, r);
    printf("%d\n", max({res.mx10, res.l[0], res.r[1]}));
  }
}
int main() {
  int T = 1;
  while (T--) solve();
}