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 + 7;
struct Node {
  int dist1, dist2, l1, r1, l2, r2;
  int inv;
  bool val;
  Node() : dist1(1), dist2(1), inv(0), val(0){};
};
Node t[4 * N];
short a[N];
bool str[N];
void upd_node(Node &v, int l, int r, Node &lef, Node &rig) {
  v.l1 = (lef.l1 != -1 ? lef.l1 : rig.l1);
  v.l2 = (lef.l2 != -1 ? lef.l2 : rig.l2);
  v.r1 = (rig.r1 != -1 ? rig.r1 : lef.r1);
  v.r2 = (rig.r2 != -1 ? rig.r2 : lef.r2);
  v.dist1 =
      max({lef.dist1, rig.dist1,
           (rig.l1 != -1 ? rig.l1 - 1 : r) - (lef.r1 != -1 ? lef.r1 : l) + 1});
  v.dist2 =
      max({lef.dist2, rig.dist2,
           (rig.l2 != -1 ? rig.l2 - 1 : r) - (lef.r2 != -1 ? lef.r2 : l) + 1});
}
void push(int v, int l, int r) {
  if (l != r) {
    t[2 * v + 1].inv += t[v].inv;
    t[2 * v + 2].inv += t[v].inv;
  }
  if (t[v].inv & 1) {
    swap(t[v].l1, t[v].l2);
    swap(t[v].r1, t[v].r2);
    swap(t[v].dist1, t[v].dist2);
    t[v].val = !t[v].val;
  }
  t[v].inv = 0;
}
void build(int v, int l, int r) {
  if (l == r) {
    t[v].l1 = t[v].r1 = (a[l] == 1 ? l : -1);
    t[v].l2 = t[v].r2 = (a[l] == 2 ? l : -1);
    t[v].val = str[l];
    return;
  }
  int m = l + r >> 1;
  build(2 * v + 1, l, m);
  build(2 * v + 2, m + 1, r);
  upd_node(t[v], l, r, t[2 * v + 1], t[2 * v + 2]);
}
void upd(int v, int l, int r, int L, int R) {
  push(v, l, r);
  if (l > R || r < L) return;
  if (l >= L && r <= R) {
    ++t[v].inv;
    push(v, l, r);
    return;
  }
  int m = l + r >> 1;
  upd(2 * v + 1, l, m, L, R);
  upd(2 * v + 2, m + 1, r, L, R);
  upd_node(t[v], l, r, t[2 * v + 1], t[2 * v + 2]);
}
void upd_one(int v, int l, int r, int pos) {
  push(v, l, r);
  if (l > pos || r < pos) return;
  if (l == pos && r == pos) {
    if (t[v].l1 == -1 && t[v].l2 == -1) {
      t[v].l1 = t[v].r1 = (!t[v].val ? l : -1);
      t[v].l2 = t[v].r2 = (t[v].val ? l : -1);
    } else
      t[v].l1 = t[v].l2 = t[v].r1 = t[v].r2 = -1;
    return;
  }
  int m = l + r >> 1;
  upd_one(2 * v + 1, l, m, pos);
  upd_one(2 * v + 2, m + 1, r, pos);
  upd_node(t[v], l, r, t[2 * v + 1], t[2 * v + 2]);
}
Node ask(int v, int l, int r, int L, int R) {
  push(v, l, r);
  if (l > R || r < L || (l >= L && r <= R)) return t[v];
  int m = l + r >> 1;
  Node lef = ask(2 * v + 1, l, m, L, R), rig = ask(2 * v + 2, m + 1, r, L, R),
       ans;
  if (m + 1 > R) return lef;
  if (m < L) return rig;
  upd_node(ans, max(l, L), min(r, R), lef, rig);
  return ans;
}
void solve() {
  int n, q;
  cin >> n >> q;
  int cur = 1;
  char lstc = 'o';
  for (int i = 0; i < (int)n; ++i) {
    char c;
    cin >> c;
    if (lstc != c) a[i] = 1 + (c == '<');
    lstc = c;
    str[i] = (c == '<');
  }
  build(0, 0, n - 1);
  for (int i = 0; i < (int)q; ++i) {
    int L, R;
    cin >> L >> R;
    --L;
    --R;
    upd(0, 0, n - 1, L, R);
    if (L) upd_one(0, 0, n - 1, L);
    if (R + 1 < n) upd_one(0, 0, n - 1, R + 1);
    cout << ask(0, 0, n - 1, L, R).dist1 << "\n";
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}