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 inf = (int)1e9;
const long long INF = (long long)5e18;
const int MOD = 998244353;
int _abs(int x) { return x < 0 ? -x : x; }
int add(int x, int y) {
  x += y;
  return x >= MOD ? x - MOD : x;
}
int sub(int x, int y) {
  x -= y;
  return x < 0 ? x + MOD : x;
}
void Add(int &x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
}
void Sub(int &x, int y) {
  x -= y;
  if (x < 0) x += MOD;
}
void Mul(int &x, int y) { x = (long long)(x) * (y) % MOD; }
int qpow(int x, int y) {
  int ret = 1;
  while (y) {
    if (y & 1) ret = (long long)(ret) * (x) % MOD;
    x = (long long)(x) * (x) % MOD;
    y >>= 1;
  }
  return ret;
}
void checkmin(int &x, int y) {
  if (x > y) x = y;
}
void checkmax(int &x, int y) {
  if (x < y) x = y;
}
void checkmin(long long &x, long long y) {
  if (x > y) x = y;
}
void checkmax(long long &x, long long y) {
  if (x < y) x = y;
}
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  return x * f;
}
const int N = 500005;
struct node {
  int l, r, lle, lri, rle, rri, lans1, lans2, rans1, rans2, ans1, ans2;
} a[N << 2];
int n, q;
char s[N];
struct Segment_Tree {
  int tag[N << 2];
  node Merge(node A, node B) {
    node ret;
    ret.l = A.l;
    ret.r = B.r;
    ret.lle = (A.lle == A.r - A.l + 1 ? A.lle + B.lle : A.lle);
    ret.lri = (A.lri == A.r - A.l + 1 ? A.lri + B.lri : A.lri);
    ret.rle = (B.rle == B.r - B.l + 1 ? B.rle + A.rle : B.rle);
    ret.rri = (B.rri == B.r - B.l + 1 ? B.rri + A.rri : B.rri);
    ret.lans1 = (A.lans1 == A.r - A.l + 1 ? A.lans1 + B.lle : A.lans1);
    if (A.lri == A.r - A.l + 1) checkmax(ret.lans1, A.lri + B.lans1);
    ret.rans1 = (B.rans1 == B.r - B.l + 1 ? B.rans1 + A.rri : B.rans1);
    if (B.rle == B.r - B.l + 1) checkmax(ret.rans1, B.rle + A.rans1);
    ret.ans1 = max(A.ans1, B.ans1);
    checkmax(ret.ans1, max(A.rans1 + B.lle, A.rri + B.lans1));
    ret.lans2 = (A.lans2 == A.r - A.l + 1 ? A.lans2 + B.lri : A.lans2);
    if (A.lle == A.r - A.l + 1) checkmax(ret.lans2, A.lle + B.lans2);
    ret.rans2 = (B.rans2 == B.r - B.l + 1 ? B.rans2 + A.rle : B.rans2);
    if (B.rri == B.r - B.l + 1) checkmax(ret.rans2, B.rri + A.rans2);
    ret.ans2 = max(A.ans2, B.ans2);
    checkmax(ret.ans2, max(A.rans2 + B.lri, A.rle + B.lans2));
    return ret;
  }
  void Rev(int x) {
    swap(a[x].lle, a[x].lri);
    swap(a[x].rle, a[x].rri);
    swap(a[x].lans1, a[x].lans2);
    swap(a[x].rans1, a[x].rans2);
    swap(a[x].ans1, a[x].ans2);
  }
  void pushdown(int x) {
    if (tag[x]) {
      tag[x << 1] ^= 1;
      tag[x << 1 | 1] ^= 1;
      Rev(x << 1);
      Rev(x << 1 | 1);
      tag[x] = 0;
    }
  }
  void build(int x, int l, int r) {
    a[x].l = l;
    a[x].r = r;
    if (l == r) {
      a[x].l = l;
      a[x].r = r;
      a[x].lans1 = 1;
      a[x].rans1 = 1;
      a[x].ans1 = 1;
      a[x].lans2 = 1;
      a[x].rans2 = 1;
      a[x].ans2 = 1;
      if (s[l] == '<')
        a[x].lle = 1, a[x].rle = 1, a[x].lri = 0, a[x].rri = 0;
      else
        a[x].lri = 1, a[x].rri = 1, a[x].lle = 0, a[x].rle = 0;
      return;
    }
    int mid = (l + r) >> 1;
    build(x << 1, l, mid);
    build(x << 1 | 1, mid + 1, r);
    a[x] = Merge(a[x << 1], a[x << 1 | 1]);
  }
  void update(int x, int l, int r, int L, int R) {
    if (L <= l && r <= R) {
      Rev(x);
      tag[x] ^= 1;
      return;
    }
    int mid = (l + r) >> 1;
    pushdown(x);
    if (mid >= L) update(x << 1, l, mid, L, R);
    if (mid < R) update(x << 1 | 1, mid + 1, r, L, R);
    a[x] = Merge(a[x << 1], a[x << 1 | 1]);
  }
  node query(int x, int l, int r, int L, int R) {
    if (l != r) pushdown(x);
    if (L <= l && r <= R) return a[x];
    int mid = (l + r) >> 1;
    if (mid < L) return query(x << 1 | 1, mid + 1, r, L, R);
    if (mid >= R) return query(x << 1, l, mid, L, R);
    return Merge(query(x << 1, l, mid, L, R),
                 query(x << 1 | 1, mid + 1, r, L, R));
  }
} T;
int main() {
  n = read();
  q = read();
  scanf("%s", s + 1);
  T.build(1, 1, n);
  while (q--) {
    int l = read(), r = read();
    T.update(1, 1, n, l, r);
    node ans = T.query(1, 1, n, l, r);
    checkmax(ans.ans1, max(ans.lle, ans.rri));
    printf("%d\n", ans.ans1);
  }
  return 0;
}