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 {
  int l0, l1, r0, r1, l10, r10, l01, r01, mx0, mx1, mx10, mx01, len, chng;
};
struct segtree {
  int size;
  vector<node> tr;
  node merge(node a, node b) {
    if (!a.len) return b;
    if (!b.len) return a;
    node rt;
    rt.chng = 0;
    rt.len = a.len + b.len;
    rt.l0 = a.l0;
    if (a.l0 == a.len) rt.l0 += b.l0;
    rt.l1 = a.l1;
    if (a.l1 == a.len) rt.l1 += b.l1;
    rt.r0 = b.r0;
    if (b.r0 == b.len) rt.r0 += a.r0;
    rt.r1 = b.r1;
    if (b.r1 == b.len) rt.r1 += a.r1;
    rt.l10 = a.l10;
    if (a.l10 == a.len) rt.l10 += b.l0;
    if (a.l1 == a.len) rt.l10 = max({rt.l10, a.l1 + b.l0, a.l1 + b.l10});
    rt.r10 = b.r10;
    if (b.r10 == b.len) rt.r10 += a.r1;
    if (b.r0 == b.len) rt.r10 = max({rt.r10, a.r10 + b.r0, a.r1 + b.r0});
    rt.l01 = a.l01;
    if (a.l01 == a.len) rt.l01 += b.l1;
    if (a.l0 == a.len) rt.l01 = max({rt.l01, a.l0 + b.l1, a.l0 + b.l01});
    rt.r01 = b.r01;
    if (b.r01 == b.len) rt.r01 += a.r0;
    if (b.r1 == b.len) rt.r01 = max({rt.r01, a.r01 + b.r1, a.r0 + b.r1});
    rt.mx0 = max({a.mx0, b.mx0, a.r0 + b.l0});
    rt.mx1 = max({a.mx1, b.mx1, a.r1 + b.l1});
    rt.mx10 = max({a.mx10, b.mx10, rt.l10, rt.r10, a.r10 + b.l0, a.r1 + b.l10});
    rt.mx01 = max({a.mx01, b.mx01, rt.l01, rt.r01, a.r01 + b.l1, a.r0 + b.l01});
    return rt;
  }
  void push(int t) {
    if (!tr[t].chng) return;
    swap(tr[t].l0, tr[t].l1);
    swap(tr[t].r0, tr[t].r1);
    swap(tr[t].l10, tr[t].l01);
    swap(tr[t].r10, tr[t].r01);
    swap(tr[t].mx0, tr[t].mx1);
    swap(tr[t].mx10, tr[t].mx01);
    if (tr[t].len > 1) {
      tr[t * 2 + 1].chng ^= 1;
      tr[t * 2 + 2].chng ^= 1;
    }
    tr[t].chng = 0;
  }
  void build(int t, int l, int r, vector<int> &v) {
    if (l + 1 == r) {
      if (v[l])
        tr[t] = {0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0};
      else
        tr[t] = {1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0};
      return;
    }
    int md = r + l >> 1;
    build(t * 2 + 1, l, md, v);
    build(t * 2 + 2, md, r, v);
    tr[t] = merge(tr[t * 2 + 1], tr[t * 2 + 2]);
  }
  segtree(vector<int> &v) : size(v.size()) {
    tr.resize(4 * size);
    build(0, 0, size, v);
  }
  void upd(int t, int l, int r, int x, int y) {
    push(t);
    if (l >= x && r <= y) {
      tr[t].chng ^= 1;
      push(t);
      return;
    }
    if (l >= y || r <= x) return;
    int md = r + l >> 1;
    upd(t * 2 + 1, l, md, x, y);
    upd(t * 2 + 2, md, r, x, y);
    tr[t] = merge(tr[t * 2 + 1], tr[t * 2 + 2]);
  }
  void upd(int l, int r) { upd(0, 0, size, l, r + 1); }
  node get(int t, int l, int r, int x, int y) {
    push(t);
    if (l >= x && r <= y) return tr[t];
    if (l >= y || r <= x) return {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    int md = r + l >> 1;
    return merge(get(t * 2 + 1, l, md, x, y), get(t * 2 + 2, md, r, x, y));
  }
  int get(int l, int r) {
    node rt = get(0, 0, size, l, r + 1);
    return rt.mx10;
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) v[i] = (s[i] == '>' ? 1 : 0);
  segtree st(v);
  for (int i = 0; i < q; ++i) {
    int l, r;
    cin >> l >> r;
    l--, r--;
    st.upd(l, r);
    int g = st.get(l, r);
    cout << g << '\n';
  }
}