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 N = 5e5 + 10, mod = 1e9 + 7;
int seg[4 * N][10], flag[4 * N];
inline void update(int ind, int s, int mid, int e) {
  seg[ind][0] = seg[2 * ind][0] +
                ((seg[2 * ind][0] == mid - s) ? seg[2 * ind + 1][0] : 0);
  seg[ind][1] = seg[2 * ind][1] +
                ((seg[2 * ind][1] == mid - s) ? seg[2 * ind + 1][1] : 0);
  seg[ind][2] = seg[2 * ind + 1][2] +
                ((seg[2 * ind + 1][2] == e - mid) ? seg[2 * ind][2] : 0);
  seg[ind][3] = seg[2 * ind + 1][3] +
                ((seg[2 * ind + 1][3] == e - mid) ? seg[2 * ind][3] : 0);
  seg[ind][4] = seg[2 * ind][4] +
                ((seg[2 * ind][4] == mid - s) ? seg[2 * ind + 1][1] : 0);
  if (seg[2 * ind][0] == mid - s &&
      max(seg[2 * ind + 1][1], seg[2 * ind + 1][4]) > 0)
    seg[ind][4] = mid - s + max(seg[2 * ind + 1][1], seg[2 * ind + 1][4]);
  seg[ind][5] = seg[2 * ind][5] +
                ((seg[2 * ind][5] == mid - s) ? seg[2 * ind + 1][0] : 0);
  if (seg[2 * ind][1] == mid - s &&
      max(seg[2 * ind + 1][0], seg[2 * ind + 1][5]) > 0)
    seg[ind][5] = mid - s + max(seg[2 * ind + 1][0], seg[2 * ind + 1][5]);
  seg[ind][6] = seg[2 * ind + 1][6] +
                ((seg[2 * ind + 1][6] == e - mid) ? seg[2 * ind][2] : 0);
  if (seg[2 * ind + 1][3] == e - mid &&
      max(seg[2 * ind][2], seg[2 * ind][6]) > 0)
    seg[ind][6] = e - mid + max(seg[2 * ind][2], seg[2 * ind][6]);
  seg[ind][7] = seg[2 * ind + 1][7] +
                ((seg[2 * ind + 1][7] == e - mid) ? seg[2 * ind][3] : 0);
  if (seg[2 * ind + 1][2] == e - mid &&
      max(seg[2 * ind][3], seg[2 * ind][7]) > 0)
    seg[ind][7] = e - mid + max(seg[2 * ind][3], seg[2 * ind][7]);
  seg[ind][8] = max(seg[2 * ind][8], seg[2 * ind + 1][8]);
  if (seg[2 * ind][6])
    seg[ind][8] = max(seg[ind][8], seg[2 * ind][6] + seg[2 * ind + 1][1]);
  if (seg[2 * ind + 1][4])
    seg[ind][8] = max(seg[ind][8], seg[2 * ind + 1][4] + seg[2 * ind][2]);
  if (seg[2 * ind][2] && seg[2 * ind + 1][1])
    seg[ind][8] = max(seg[ind][8], seg[2 * ind][2] + seg[2 * ind + 1][1]);
  seg[ind][9] = max(seg[2 * ind][9], seg[2 * ind + 1][9]);
  if (seg[2 * ind][7])
    seg[ind][9] = max(seg[ind][9], seg[2 * ind][7] + seg[2 * ind + 1][0]);
  if (seg[2 * ind + 1][5])
    seg[ind][9] = max(seg[ind][9], seg[2 * ind + 1][5] + seg[2 * ind][3]);
  if (seg[2 * ind][3] && seg[2 * ind + 1][0])
    seg[ind][9] = max(seg[ind][9], seg[2 * ind][3] + seg[2 * ind + 1][0]);
}
void build(int s, int e, int ind, int l, int r, int val) {
  if (s >= r || e <= l) return;
  if (s >= l && e <= r) {
    if (val == 1) {
      seg[ind][0] = 1;
      seg[ind][2] = 1;
    } else {
      seg[ind][1] = 1;
      seg[ind][3] = 1;
    }
    return;
  }
  int mid = (s + e) / 2;
  build(s, mid, 2 * ind, l, r, val);
  build(mid, e, 2 * ind + 1, l, r, val);
  update(ind, s, mid, e);
}
void relax(int ind) {
  if (flag[ind] != -1) return;
  flag[ind] = 1;
  flag[2 * ind] *= -1;
  flag[2 * ind + 1] *= -1;
  for (int i = 0; i < 10; i += 2) {
    swap(seg[2 * ind][i], seg[2 * ind][i + 1]);
    swap(seg[2 * ind + 1][i], seg[2 * ind + 1][i + 1]);
  }
}
void change(int s, int e, int ind, int l, int r) {
  if (s >= r || e <= l) return;
  if (s >= l && e <= r) {
    for (int i = 0; i < 10; i += 2) swap(seg[ind][i], seg[ind][i + 1]);
    flag[ind] *= -1;
    return;
  }
  relax(ind);
  int mid = (s + e) / 2;
  change(s, mid, 2 * ind, l, r);
  change(mid, e, 2 * ind + 1, l, r);
  update(ind, s, mid, e);
}
int get(int s, int e, int ind, int l, int r) {
  if (s >= r || e <= l) return 0;
  if (s >= l && e <= r) {
    int ret = 0;
    for (int i = 0; i < 10; i++)
      if (i != 5 && i != 7 && i != 9) ret = max(ret, seg[ind][i]);
    return ret;
  }
  relax(ind);
  int mid = (s + e) / 2;
  int ret = max(get(s, mid, 2 * ind, l, r), get(mid, e, 2 * ind + 1, l, r));
  ret = max(
      ret,
      max(min(seg[2 * ind][2], mid - l) + min(seg[2 * ind + 1][0], r - mid),
          min(seg[2 * ind][3], mid - l) + min(seg[2 * ind + 1][1], r - mid)));
  ret = max(
      ret,
      max(min(seg[2 * ind][6], mid - l) + min(seg[2 * ind + 1][1], r - mid),
          min(seg[2 * ind][2], mid - l) + min(seg[2 * ind + 1][4], r - mid)));
  ret = max(ret,
            min(seg[2 * ind][2], mid - l) + min(seg[2 * ind + 1][1], r - mid));
  return ret;
}
int a[N];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  for (int i = 0; i < 4 * N; i++) flag[i] = 1;
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  for (int i = 0; i < n; i++) {
    if (s[i] == '>')
      a[i] = 1;
    else
      a[i] = -1;
    build(0, n, 1, i, i + 1, a[i]);
  }
  while (q--) {
    int l, r;
    cin >> l >> r;
    l--;
    change(0, n, 1, l, r);
    cout << get(0, n, 1, l, r) << "\n";
  }
  return 0;
}