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>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
using namespace std;
const int N = 5e5 + 100;
struct Node {
  int l1 = 0, l0 = 0, r1 = 0, r0 = 0, mx01 = 0, mx10 = 0, mxl10 = 0, mxl01 = 0,
      mxr01 = 0, mxr10 = 0;
} seg[N * 4];
Node mr;
int lazy[N * 4];
void mrg(Node a, Node b, int l, int r, int mid) {
  mr.mx10 = max(a.mx10, max(b.mx10, max(a.mxr10 + b.l0, a.r1 + b.mxl10)));
  mr.mx01 = max(a.mx01, max(b.mx01, max(a.mxr01 + b.l1, a.r0 + b.mxl01)));
  mr.l0 = a.l0;
  mr.l1 = a.l1;
  mr.r0 = b.r0;
  mr.r1 = b.r1;
  mr.mxl01 = a.mxl01;
  mr.mxl10 = a.mxl10;
  mr.mxr10 = b.mxr10;
  mr.mxr01 = b.mxr01;
  if (a.l0 == mid - l) {
    mr.l0 += b.l0;
    mr.mxl01 += b.mxl01;
  }
  if (a.l1 == mid - l) {
    mr.l1 += b.l1;
    mr.mxl10 += b.mxl10;
  }
  if (b.r0 == r - mid) {
    mr.r0 += a.r0;
    mr.mxr10 += a.mxr10;
  }
  if (b.r1 == r - mid) {
    mr.r1 += a.r1;
    mr.mxr01 += a.mxr01;
  }
  if (a.mxl01 == mid - l) {
    mr.mxl01 = max(mr.mxl01, mid - l + b.l1);
  }
  if (a.mxl10 == mid - l) {
    mr.mxl10 = max(mr.mxl10, mid - l + b.l0);
  }
  if (b.mxr01 == r - mid) {
    mr.mxr01 = max(mr.mxr01, r - mid + a.r0);
  }
  if (b.mxr10 == r - mid) {
    mr.mxr10 = max(mr.mxr10, r - mid + a.r1);
  }
  mr.mxl01 = max(mr.mxl01, max(mr.l1, mr.l0));
  mr.mxl10 = max(mr.mxl10, max(mr.l0, mr.l1));
  mr.mxr01 = max(mr.mxr01, max(mr.r0, mr.r1));
  mr.mxr10 = max(mr.mxr10, max(mr.r1, mr.r0));
  mr.mx01 = max(mr.mx01, max(mr.mxl01, mr.mxr01));
  mr.mx10 = max(mr.mx10, max(mr.mxl10, mr.mxr10));
}
void cng(int nod) {
  swap(seg[nod].l0, seg[nod].l1);
  swap(seg[nod].r0, seg[nod].r1);
  swap(seg[nod].mx01, seg[nod].mx10);
  swap(seg[nod].mxl01, seg[nod].mxl10);
  swap(seg[nod].mxr01, seg[nod].mxr10);
  return;
}
void shift(int nod) {
  if (!lazy[nod]) return;
  lazy[nod] = 0;
  lazy[nod * 2] ^= 1;
  lazy[nod * 2 + 1] ^= 1;
  cng(nod * 2);
  cng(nod * 2 + 1);
}
char a[N];
void build(int nod, int l, int r) {
  if (r - l == 1) {
    if (a[l] == '>') {
      seg[nod].l0 = 1, seg[nod].r0 = 1, seg[nod].mx01 = 1, seg[nod].mx10 = 1,
      seg[nod].mxl01 = 1, seg[nod].mxl10 = 1, seg[nod].mxr01 = 1,
      seg[nod].mxr10 = 1;
    } else {
      seg[nod].l1 = 1, seg[nod].r1 = 1, seg[nod].mx01 = 1, seg[nod].mx10 = 1,
      seg[nod].mxl01 = 1, seg[nod].mxl10 = 1, seg[nod].mxr01 = 1,
      seg[nod].mxr10 = 1;
    }
    return;
  }
  int mid = (r + l) / 2;
  build(nod * 2, l, mid);
  build(nod * 2 + 1, mid, r);
  mrg(seg[nod * 2], seg[nod * 2 + 1], l, r, mid);
  seg[nod] = mr;
  return;
}
void upd(int nod, int l, int r, int L, int R) {
  if (l >= R || L >= r) return;
  if (l >= L && r <= R) {
    lazy[nod] ^= 1;
    cng(nod);
    return;
  }
  int mid = (r + l) / 2;
  shift(nod);
  upd(nod * 2, l, mid, L, R);
  upd(nod * 2 + 1, mid, r, L, R);
  mrg(seg[nod * 2], seg[nod * 2 + 1], l, r, mid);
  seg[nod] = mr;
  return;
}
void get(int nod, int l, int r, int L, int R) {
  if (l >= R || L >= r) return;
  if (l >= L && r <= R) {
    mrg(mr, seg[nod], L, r, l);
    return;
  }
  shift(nod);
  int mid = (r + l) / 2;
  get(nod * 2, l, mid, L, R);
  get(nod * 2 + 1, mid, r, L, R);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, q;
  cin >> n >> q;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  build(1, 1, n + 1);
  mr.l1 = 0, mr.l0 = 0, mr.r1 = 0, mr.r0 = 0, mr.mx01 = 0, mr.mx10 = 0,
  mr.mxl10 = 0, mr.mxl01 = 0, mr.mxr01 = 0, mr.mxr10 = 0;
  get(1, 1, n + 1, 1, 6);
  while (q--) {
    mr.l1 = 0, mr.l0 = 0, mr.r1 = 0, mr.r0 = 0, mr.mx01 = 0, mr.mx10 = 0,
    mr.mxl10 = 0, mr.mxl01 = 0, mr.mxr01 = 0, mr.mxr10 = 0;
    int l, r;
    cin >> l >> r;
    r++;
    upd(1, 1, n + 1, l, r);
    mr.l1 = 0, mr.l0 = 0, mr.r1 = 0, mr.r0 = 0, mr.mx01 = 0, mr.mx10 = 0,
    mr.mxl10 = 0, mr.mxl01 = 0, mr.mxr01 = 0, mr.mxr10 = 0;
    get(1, 1, n + 1, l, r);
    cout << mr.mx01 << '\n';
  }
}