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, Q;
string s;
struct Info {
  int len;
  int l_len, r_len;
  char left, right;
  int ans;
  void Output() {
    printf("len=%d l_len=%d r_len=%d left=\'%c\' right=\'%c\' ans=%d\n", len,
           l_len, r_len, left, right, ans);
  }
};
class TreeNode {
 public:
  TreeNode *lch, *rch;
  int l, r;
  bool tag;
  Info front, back;
  TreeNode(int l, int r) : l(l), r(r) { tag = false; }
  void TurnOver() {
    tag = !tag;
    swap(front, back);
  }
  void PushDown() {
    if (tag) {
      tag = false;
      lch->TurnOver();
      rch->TurnOver();
    }
  }
  void Update() {
    front = Merge(lch->front, rch->front);
    back = Merge(lch->back, rch->back);
  }
  void Output() {
    printf("l: %d  r: %d  tag: %s\n", l, r, tag ? "true" : "false");
    printf("front: ");
    front.Output();
    printf("back: ");
    back.Output();
  }
  static Info Merge(const Info& a, const Info& b) {
    Info now;
    now.len = a.len + b.len;
    now.left = a.left;
    now.right = b.right;
    now.ans = max(a.ans, b.ans);
    if ((a.right == '<' && b.left == '<') ||
        (a.right == '>' && b.left == '>') ||
        (a.right == '>' && b.left == '<')) {
      if (a.r_len == a.len) {
        now.l_len = a.len + b.l_len;
      } else {
        now.l_len = a.l_len;
      }
      if (b.l_len == b.len) {
        now.r_len = b.len + a.r_len;
      } else {
        now.r_len = b.r_len;
      }
      now.ans = max(now.ans, a.r_len + b.l_len);
    } else {
      now.l_len = a.l_len;
      now.r_len = b.r_len;
    }
    return now;
  }
};
TreeNode* BuildTree(const string& s, int l, int r) {
  auto v = new TreeNode(l, r);
  if (l == r) {
    v->front.len = 1;
    v->front.l_len = v->front.r_len = 1;
    v->front.left = v->front.right = '<';
    v->front.ans = 1;
    v->back.len = 1;
    v->back.l_len = v->back.r_len = 1;
    v->back.left = v->back.right = '>';
    v->back.ans = 1;
    if (s[l] == '>') swap(v->front, v->back);
    return v;
  }
  int mid = (l + r) / 2;
  v->lch = BuildTree(s, l, mid);
  v->rch = BuildTree(s, mid + 1, r);
  v->Update();
  return v;
}
void Change(TreeNode* v, int ww, int ee, vector<TreeNode*>& visit) {
  if (ww <= v->l && v->r <= ee) {
    v->TurnOver();
    visit.push_back(v);
    return;
  }
  v->PushDown();
  int mid = (v->l + v->r) / 2;
  if (ww <= mid) Change(v->lch, ww, ee, visit);
  if (ee > mid) Change(v->rch, ww, ee, visit);
  v->Update();
}
int main() {
  cin >> N >> Q;
  cin >> s;
  auto root = BuildTree(s, 0, N - 1);
  vector<TreeNode*> visit;
  for (int i = 0; i < Q; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    visit.clear();
    Change(root, a, b, visit);
    Info info = visit[0]->front;
    for (int i = 1; i < visit.size(); i++) {
      info = TreeNode::Merge(info, visit[i]->front);
    }
    cout << info.ans << endl;
  }
  return 0;
}