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 node {
  bool dirpre, dirsuf;
  int len;
  int mx, pre, suf;
  int mx2, pre2, suf2;
  node(bool dirpre, bool dirsuf, int mx, int len, int pre, int suf, int pre2,
       int suf2, int mx2)
      : dirpre(dirpre),
        dirsuf(dirsuf),
        mx(mx),
        len(len),
        pre(pre),
        suf(suf),
        pre2(pre2),
        suf2(suf2),
        mx2(mx2) {}
  node() {}
};
node NEUT = node(-1, -1, -1, -1, -1, -1, -1, -1, -1);
node merge(node &a, node &b) {
  if (min(a.len, b.len) < 0) return a.len < 0 ? b : a;
  node ans;
  ans.dirpre = a.dirpre;
  ans.dirsuf = b.dirsuf;
  ans.len = a.len + b.len;
  ans.suf = b.suf;
  if (b.suf == b.len && (a.dirsuf != 0 || b.dirpre != 1)) ans.suf += a.suf;
  ans.pre = a.pre;
  if (a.pre == a.len && (a.dirsuf != 0 || b.dirpre != 1)) ans.pre += b.pre;
  ans.mx = max({a.mx, b.mx, ans.suf, ans.pre});
  if (a.dirsuf != 0 || b.dirpre != 1) ans.mx = max(ans.mx, a.suf + b.pre);
  ans.suf2 = b.suf2;
  if (b.suf2 == b.len && (a.dirsuf != 1 || b.dirpre != 0)) ans.suf2 += a.suf2;
  ans.pre2 = a.pre2;
  if (a.pre2 == a.len && (a.dirsuf != 1 || b.dirpre != 0)) ans.pre2 += b.pre2;
  ans.mx2 = max({a.mx2, b.mx2, ans.suf2, ans.pre2});
  if (a.dirsuf != 1 || b.dirpre != 0) ans.mx2 = max(ans.mx2, a.suf2 + b.pre2);
  return ans;
}
struct STree {
  vector<node> st;
  vector<int> lazy;
  int n;
  STree(int n) : st(4 * n + 5, NEUT), lazy(4 * n + 5, 0), n(n) {}
  void init(int k, int s, int e, vector<int> &a) {
    lazy[k] = 0;
    if (s + 1 == e) {
      st[k] = node(a[s], a[s], 1, 1, 1, 1, 1, 1, 1);
      return;
    }
    int m = (s + e) / 2;
    init(2 * k, s, m, a);
    init(2 * k + 1, m, e, a);
    st[k] = merge(st[2 * k], st[2 * k + 1]);
  }
  void push(int k, int s, int e) {
    if (!lazy[k]) return;
    swap(st[k].mx, st[k].mx2);
    swap(st[k].pre, st[k].pre2);
    swap(st[k].suf, st[k].suf2);
    st[k].dirpre ^= 1;
    st[k].dirsuf ^= 1;
    if (s + 1 < e) {
      lazy[2 * k] ^= lazy[k];
      lazy[2 * k + 1] ^= lazy[k];
    }
    lazy[k] = 0;
  }
  void upd(int k, int s, int e, int a, int b, int v) {
    push(k, s, e);
    if (s >= b || e <= a) return;
    if (s >= a && e <= b) {
      lazy[k] ^= 1;
      push(k, s, e);
      return;
    }
    int m = (s + e) / 2;
    upd(2 * k, s, m, a, b, v);
    upd(2 * k + 1, m, e, a, b, v);
    st[k] = merge(st[2 * k], st[2 * k + 1]);
  }
  node query(int k, int s, int e, int a, int b) {
    if (s >= b || e <= a) return NEUT;
    push(k, s, e);
    if (s >= a && e <= b) return st[k];
    int m = (s + e) / 2;
    node l = query(2 * k, s, m, a, b);
    node r = query(2 * k + 1, m, e, a, b);
    return merge(l, r);
  }
  void init(vector<int> &a) { init(1, 0, n, a); }
  void upd(int a, int b, int v) { upd(1, 0, n, a, b, v); }
  node query(int a, int b) { return query(1, 0, n, a, b); }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<int> a(n);
  for (int i = 0, ThxDem = n; i < ThxDem; ++i) a[i] = s[i] == '>';
  STree st(n);
  st.init(a);
  while (q--) {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    st.upd(l, r + 1, 1);
    node ans = st.query(l, r + 1);
    cout << ans.mx << "\n";
  }
}