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;
struct data {
  int max_dif[2];
  int left[2], right[2];
  int cnt[4];
  bool rev_ch;
  void init() {
    rev_ch = false;
    max_dif[0] = max_dif[1] = -1000000000;
    left[0] = left[1] = -1000000000;
    right[0] = right[1] = 1000000000;
    cnt[0] = cnt[1] = cnt[2] = cnt[3] = 0;
  }
} S[500005 << 2];
int n, q;
string s;
data merge(data L, data R) {
  data result;
  result.init();
  for (int i = 0; i < 2; i++) {
    result.max_dif[i] = max(L.max_dif[i], R.max_dif[i]);
    result.max_dif[i] = max(result.max_dif[i], R.left[i] - L.right[i]);
    result.left[i] = L.left[i];
    result.right[i] = R.right[i];
    if (result.left[i] == -1000000000) result.left[i] = R.left[i];
    if (result.right[i] == 1000000000) result.right[i] = L.right[i];
    result.cnt[i] = L.cnt[i] + R.cnt[i];
  }
  for (int i = 2; i < 4; i++) result.cnt[i] = L.cnt[i] + R.cnt[i];
  return result;
}
void relax(int node) {
  data& cur = S[node];
  cur.rev_ch ^= true;
  swap(cur.max_dif[0], cur.max_dif[1]);
  swap(cur.left[0], cur.left[1]);
  swap(cur.right[0], cur.right[1]);
  swap(cur.cnt[0], cur.cnt[1]);
  swap(cur.cnt[2], cur.cnt[3]);
}
void push(int node) {
  if (S[node].rev_ch) {
    S[node].rev_ch = false;
    relax(node << 1);
    relax(node << 1 | 1);
  }
}
data get(int node, int l, int r, int q_l, int q_r) {
  if (l >= q_l and r <= q_r) return S[node];
  push(node);
  int mid = (l + r) >> 1;
  bool go_l = (mid >= q_l);
  bool go_r = (mid + 1 <= q_r);
  if (go_l and go_r) {
    data L = get(node << 1, l, mid, q_l, q_r);
    data R = get(node << 1 | 1, mid + 1, r, q_l, q_r);
    return merge(L, R);
  }
  if (go_l) return get(node << 1, l, mid, q_l, q_r);
  return get(node << 1 | 1, mid + 1, r, q_l, q_r);
}
void update(int node, int l, int r, int pos, int w) {
  data& cur = S[node];
  if (l == pos and r == pos) {
    int cnt[4] = {0};
    for (int i = 0; i < 4; i++) cnt[i] = cur.cnt[i];
    cur.init();
    for (int i = 0; i < 4; i++) cur.cnt[i] = cnt[(3 - i) ^ (!w)];
    if (cur.cnt[0]) cur.left[0] = cur.right[0] = l;
    if (cur.cnt[1]) cur.left[1] = cur.right[1] = l;
    return;
  }
  push(node);
  int mid = (l + r) >> 1;
  if (mid >= pos)
    update(node << 1, l, mid, pos, w);
  else
    update(node << 1 | 1, mid + 1, r, pos, w);
  cur = merge(S[node << 1], S[node << 1 | 1]);
}
void revert(int node, int l, int r, int q_l, int q_r) {
  data& cur = S[node];
  if (l >= q_l and r <= q_r) {
    relax(node);
    return;
  }
  push(node);
  int mid = (l + r) >> 1;
  bool go_l = (mid >= q_l);
  bool go_r = (mid + 1 <= q_r);
  if (go_l) revert(node << 1, l, mid, q_l, q_r);
  if (go_r) revert(node << 1 | 1, mid + 1, r, q_l, q_r);
  cur = merge(S[node << 1], S[node << 1 | 1]);
}
void build(int node, int l, int r) {
  data& cur = S[node];
  if (l == r) {
    cur.init();
    if (l == 0) {
      cur.cnt[(s[l] == '<')] = 1;
      cur.left[(s[l] == '<')] = l;
      cur.right[(s[l] == '<')] = l;
    } else if (l == n) {
      cur.cnt[(s[n - 1] == '>')] = 1;
      cur.left[(s[n - 1] == '>')] = l;
      cur.right[(s[n - 1] == '>')] = l;
    } else {
      if (s[l - 1] == '>' and s[l] == '<') {
        cur.cnt[1] = 1;
        cur.left[1] = l;
        cur.right[1] = l;
      } else if (s[l - 1] == '<' and s[l] == '>') {
        cur.cnt[0] = 1;
        cur.left[0] = l;
        cur.right[0] = l;
      } else if (s[l - 1] == '>' and s[l] == '>') {
        cur.cnt[2] = 1;
      } else {
        cur.cnt[3] = 1;
      }
    }
    return;
  }
  int mid = (l + r) >> 1;
  build(node << 1, l, mid);
  build(node << 1 | 1, mid + 1, r);
  cur = merge(S[node << 1], S[node << 1 | 1]);
}
void debug_array() {
  vector<int> holes;
  for (int i = 0; i <= n; i++) {
    data result = get(1, 0, n, i, i);
    for (int j = 0; j < 4; j++)
      if (result.cnt[j]) holes.push_back(j);
  }
  assert(((int)holes.size()) == n + 1);
  for (int i = 1; i <= n; i++) {
    if (holes[i] == 1 or holes[i] == 2)
      cerr << '>';
    else
      cerr << '<';
  }
  cerr << "\n";
}
void solve() {
  cin >> n >> q;
  cin >> s;
  build(1, 0, n);
  while (q--) {
    int l, r;
    cin >> l >> r;
    revert(1, 0, n, l, r - 1);
    update(1, 0, n, l - 1, 1);
    update(1, 0, n, r, 0);
    data result = get(1, 0, n, l - 1, r);
    int ans = result.max_dif[0];
    ans = max(ans, r - result.right[0]);
    ans = max(ans, result.left[0] - l + 1);
    if (ans <= 0) ans = r - l + 1;
    cout << ans << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) solve();
}