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;
string s;
const int LEFT = 0, RIGHT = 1;
namespace seg {
struct node {
  node *lc, *rc;
  int l1, r1, l2, r2, v1, v2;
  int ldir, rdir;
  bool lazy;
  void upd(int l, int r) {
    int m = (l + r) / 2;
    ldir = lc->ldir;
    rdir = rc->rdir;
    if ((l1 = lc->l1) == m - l && (rc->ldir == LEFT || lc->rdir == RIGHT))
      l1 += rc->l1;
    if ((l2 = lc->l2) == m - l && (rc->ldir != LEFT || lc->rdir != RIGHT))
      l2 += rc->l2;
    if ((r1 = rc->r1) == r - m && (lc->rdir == RIGHT || rc->ldir == LEFT))
      r1 += lc->r1;
    if ((r2 = rc->r2) == r - m && (lc->rdir != RIGHT || rc->ldir != LEFT))
      r2 += lc->r2;
    v1 = max(lc->v1, rc->v1);
    if (lc->rdir == RIGHT || rc->ldir == LEFT) v1 = max(v1, lc->r1 + rc->l1);
    v2 = max(lc->v2, rc->v2);
    if (lc->rdir != RIGHT || rc->ldir != LEFT) v2 = max(v2, lc->r2 + rc->l2);
  }
  void flip() {
    lazy ^= 1, ldir ^= 1, rdir ^= 1;
    swap(l1, l2), swap(r1, r2), swap(v1, v2);
  }
};
node* init(int l, int r) {
  node* n = new node;
  n->lazy = 0;
  if (l + 1 == r) {
    n->v1 = n->v2 = n->l1 = n->l2 = n->r1 = n->r2 = 1;
    n->ldir = n->rdir = s[l] == '>' ? RIGHT : LEFT;
  } else {
    int m = (l + r) / 2;
    n->lc = init(l, m);
    n->rc = init(m, r);
    n->upd(l, r);
  }
  return n;
}
node* root;
int n, ql, qr;
int query(node* n, int l, int r) {
  if (l >= qr || r <= ql) return 0;
  if (l >= ql && r <= qr) {
    n->flip();
    return n->v1;
  } else {
    if (n->lazy) {
      n->lazy = 0;
      n->lc->flip();
      n->rc->flip();
    }
    int m = (l + r) / 2;
    int lv = query(n->lc, l, m);
    int rv = query(n->rc, m, r);
    n->upd(l, r);
    int ans = max(lv, rv);
    if (ql < m && m < qr && (n->lc->rdir == RIGHT || n->rc->ldir == LEFT))
      ans = max(ans, min(m - ql, n->lc->r1) + min(qr - m, n->rc->l1));
    return ans;
  }
}
int query(int l, int r) {
  ql = l, qr = r;
  return query(root, 0, n);
}
void init() {
  n = s.size();
  root = init(0, n);
}
}  // namespace seg
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int n, q;
  cin >> n >> q;
  cin >> s;
  seg::init();
  while (q--) {
    int l, r;
    cin >> l >> r;
    cout << seg::query(l - 1, r) << '\n';
  }
}