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;
int a[500011], b[500011];
int BIT[500011];
void upd_BIT(int x, int val) {
  for (; x <= n; x += x & (-x)) BIT[x] += val;
}
int query_BIT(int x) {
  int ans = 0;
  for (; x > 0; x -= x & (-x)) ans += BIT[x];
  return ans;
}
struct Node {
  int f[3], lazy, l[3], r[3];
  Node() {
    lazy = 0;
    for (int i = 1; i <= 2; i++) {
      l[i] = 1e9;
      r[i] = -1e9;
      f[i] = -1e9;
    }
  }
} Seg[2000011];
void change_Seg(int node, int l, int r) {
  for (int i = 1; i <= 2; i++) {
    Seg[node].l[i] = min(Seg[node * 2].l[i], Seg[node * 2 + 1].l[i]);
    Seg[node].r[i] = max(Seg[node * 2].r[i], Seg[node * 2 + 1].r[i]);
    Seg[node].f[i] = max(Seg[node * 2].f[i], Seg[node * 2 + 1].f[i]);
    if (Seg[node * 2].r[i] != -1e9 && Seg[node * 2 + 1].l[i] != 1e9)
      Seg[node].f[i] =
          max(Seg[node].f[i], Seg[node * 2 + 1].l[i] - Seg[node * 2].r[i]);
    if (Seg[node].l[i] != 1e9)
      Seg[node].f[i] = max(Seg[node].f[i], Seg[node].l[i] - l);
    if (Seg[node].r[i] != -1e9)
      Seg[node].f[i] = max(Seg[node].f[i], r - Seg[node].r[i] + 1);
  }
}
void build_Seg(int node, int l, int r) {
  if (l == r) {
    if (b[l] == 1) {
      Seg[node].f[1] = 1;
      Seg[node].l[1] = Seg[node].r[1] = l;
    }
    if (b[l] == -1) {
      Seg[node].f[2] = 1;
      Seg[node].l[2] = Seg[node].r[2] = l;
    }
    return;
  }
  int mi = (l + r) / 2;
  build_Seg(node * 2, l, mi);
  build_Seg(node * 2 + 1, mi + 1, r);
  change_Seg(node, l, r);
}
void diffuse_Seg(int node, int l, int r) {
  if (Seg[node].lazy % 2) {
    swap(Seg[node].l[1], Seg[node].l[2]);
    swap(Seg[node].r[1], Seg[node].r[2]);
    swap(Seg[node].f[1], Seg[node].f[2]);
    if (l != r) {
      Seg[node * 2].lazy++;
      Seg[node * 2 + 1].lazy++;
    }
    Seg[node].lazy = 0;
  }
}
void upd_Seg(int node, int l, int r, int ll, int rr) {
  diffuse_Seg(node, l, r);
  if (r < ll || rr < l) return;
  if (ll <= l && r <= rr) {
    Seg[node].lazy++;
    diffuse_Seg(node, l, r);
    return;
  }
  int mi = (l + r) / 2;
  upd_Seg(node * 2, l, mi, ll, rr);
  upd_Seg(node * 2 + 1, mi + 1, r, ll, rr);
  change_Seg(node, l, r);
}
void upd_Seg_point(int node, int l, int r, int x) {
  diffuse_Seg(node, l, r);
  if (x < l || r < x) return;
  if (l == r) {
    int cur = (a[l] + query_BIT(l)) % 2 - (a[l - 1] + query_BIT(l - 1)) % 2;
    for (int i = 1; i <= 2; i++) {
      Seg[node].l[i] = 1e9;
      Seg[node].r[i] = -1e9;
      Seg[node].f[i] = -1e9;
    }
    if (cur == 1) {
      Seg[node].f[1] = 1;
      Seg[node].l[1] = Seg[node].r[1] = l;
    }
    if (cur == -1) {
      Seg[node].f[2] = 1;
      Seg[node].l[2] = Seg[node].r[2] = l;
    }
    return;
  }
  int mi = (l + r) / 2;
  upd_Seg_point(node * 2, l, mi, x);
  upd_Seg_point(node * 2 + 1, mi + 1, r, x);
  change_Seg(node, l, r);
}
Node query_Seg(int node, int l, int r, int ll, int rr) {
  diffuse_Seg(node, l, r);
  if (r < ll || rr < l) return Node();
  if (ll <= l && r <= rr) return Seg[node];
  int mi = (l + r) / 2;
  Node a = query_Seg(node * 2, l, mi, ll, rr);
  Node b = query_Seg(node * 2 + 1, mi + 1, r, ll, rr);
  Node c;
  for (int i = 1; i <= 2; i++) {
    c.l[i] = min(a.l[i], b.l[i]);
    c.r[i] = max(a.r[i], b.r[i]);
    c.f[i] = max(a.f[i], b.f[i]);
    if (a.r[i] != -1e9 && b.l[i] != 1e9) c.f[i] = max(c.f[i], b.l[i] - a.r[i]);
    if (c.l[i] != 1e9) c.f[i] = max(c.f[i], c.l[i] - max(l, ll));
    if (c.r[i] != -1e9) c.f[i] = max(c.f[i], min(r, rr) - c.r[i] + 1);
  }
  return c;
}
int main(int argc, char** argv) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  cin >> s;
  for (int i = 1; i <= n; i++) {
    a[i] = (s[i - 1] == '<');
    b[i] = a[i] - a[i - 1];
  }
  build_Seg(1, 1, n);
  for (int i = 1; i <= q; i++) {
    int l, r;
    cin >> l >> r;
    upd_BIT(l, 1);
    upd_BIT(r + 1, -1);
    upd_Seg_point(1, 1, n, l);
    if (r != n) upd_Seg_point(1, 1, n, r + 1);
    if (l < r) upd_Seg(1, 1, n, l + 1, r);
    Node ans = query_Seg(1, 1, n, l, r);
    cout << ((ans.f[2] == -1e9) ? r - l + 1 : ans.f[2]) << '\n';
  }
}