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>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
const ll N = 5e5 + 10, p1 = 911382323, p2 = 972663749, mod = 1e9 + 123;
inline int read() {
  char c = getchar();
  bool minus = 0;
  while (c < '0' || '9' < c) {
    if (c == '-') {
      minus = 1;
    }
    c = getchar();
    if (c == '-') {
      minus = 1;
    }
  }
  int res = 0;
  while ('0' <= c && c <= '9') {
    res = (res << 3) + (res << 1) + c - '0';
    c = getchar();
  }
  if (minus) {
    res *= -1;
  }
  return res;
}
inline string readStr() {
  char c = getchar();
  while (c != '>' && c != '<') {
    c = getchar();
  }
  string res = "";
  while (c == '>' || c == '<') {
    res += c;
    c = getchar();
  }
  return res;
}
int n, m, a[N];
struct node {
  int black_pfx, white_pfx, black_sfx, white_sfx, wsbbs, bsawp;
  int sum, len, seg01, seg0, seg1, seg10, wsabp, bsbws;
  node() {
    black_pfx = 0;
    white_pfx = 0;
    wsbbs = 0;
    sum = 0;
    seg01 = 0;
    seg10 = 0;
    wsabp = 0;
    black_sfx = 0;
    white_sfx = 0;
    bsawp = 0;
    len = 0;
    seg0 = 0;
    seg1 = 0;
    bsbws = 0;
  }
};
node t[N << 2];
int tRev[N << 2];
node unite(node L, node R) {
  node M = node();
  M.sum = L.sum + R.sum;
  M.len = L.len + R.len;
  if (L.sum == L.len) {
    M.black_pfx = L.len + R.black_pfx;
    M.wsabp = R.wsabp;
  } else {
    M.black_pfx = L.black_pfx;
    if (L.wsabp == L.len - L.black_pfx) {
      M.wsabp = L.wsabp + R.white_pfx;
    } else {
      M.wsabp = L.wsabp;
    }
  }
  if (L.sum == 0) {
    M.white_pfx = L.len + R.white_pfx;
    M.bsawp = R.bsawp;
  } else {
    M.white_pfx = L.white_pfx;
    if (L.bsawp == L.len - L.white_pfx) {
      M.bsawp = L.bsawp + R.black_pfx;
    } else {
      M.bsawp = L.bsawp;
    }
  }
  if (R.sum == 0) {
    M.white_sfx = R.len + L.white_sfx;
    M.bsbws = L.bsbws;
  } else {
    M.white_sfx = R.white_sfx;
    if (R.bsbws == R.len - R.white_sfx) {
      M.bsbws = R.bsbws + L.black_sfx;
    } else {
      M.bsbws = R.bsbws;
    }
  }
  if (R.sum == R.len) {
    M.black_sfx = R.len + L.black_sfx;
    M.wsbbs = L.wsbbs;
  } else {
    M.black_sfx = R.black_sfx;
    if (R.wsbbs == R.len - R.black_sfx) {
      M.wsbbs = R.wsbbs + L.white_sfx;
    } else {
      M.wsbbs = R.wsbbs;
    }
  }
  M.seg01 = max(L.white_sfx + R.white_pfx + R.bsawp,
                L.wsbbs + L.black_sfx + R.black_pfx);
  M.seg01 = max(M.seg01, max(L.seg01, R.seg01));
  M.seg10 = max(L.black_sfx + R.black_pfx + R.wsabp,
                L.bsbws + L.white_sfx + R.white_pfx);
  M.seg10 = max(M.seg10, max(L.seg10, R.seg10));
  M.seg0 = max(L.white_sfx + R.white_pfx, max(L.seg0, R.seg0));
  M.seg1 = max(L.black_sfx + R.black_pfx, max(L.seg1, R.seg1));
  return M;
}
void build(int v, int vl, int vr) {
  if (vl == vr) {
    t[v] = node();
    t[v].black_sfx = (a[vl] == 1);
    t[v].black_pfx = (a[vl] == 1);
    t[v].white_sfx = (a[vl] == 0);
    t[v].white_pfx = (a[vl] == 0);
    t[v].bsawp = (a[vl] == 1);
    t[v].sum = a[vl];
    t[v].seg01 = 0;
    t[v].wsbbs = (a[vl] == 0);
    t[v].len = 1;
    t[v].seg10 = 0;
    t[v].seg1 = (a[vl] == 1);
    t[v].seg0 = (a[vl] == 0);
    t[v].wsabp = (a[vl] == 0);
    t[v].bsbws = (a[vl] == 1);
    return;
  }
  int vm = (vl + vr) >> 1;
  build(v * 2 + 1, vl, vm);
  build(v * 2 + 2, vm + 1, vr);
  t[v] = unite(t[v * 2 + 1], t[v * 2 + 2]);
}
void push(int v, int vl, int vr) {
  if (tRev[v]) {
    t[v].sum = t[v].len - t[v].sum;
    swap(t[v].black_sfx, t[v].white_sfx);
    swap(t[v].black_pfx, t[v].white_pfx);
    swap(t[v].seg1, t[v].seg0);
    swap(t[v].seg01, t[v].seg10);
    swap(t[v].wsbbs, t[v].bsbws);
    swap(t[v].bsawp, t[v].wsabp);
    if (vl != vr) {
      tRev[v * 2 + 1] ^= 1;
      tRev[v * 2 + 2] ^= 1;
    }
    tRev[v] = 0;
  }
}
void modify(int v, int vl, int vr, int l, int r) {
  push(v, vl, vr);
  if (vl > r || vr < l) {
    return;
  }
  if (l <= vl && vr <= r) {
    tRev[v] = 1;
    push(v, vl, vr);
    return;
  }
  int vm = (vl + vr) >> 1;
  modify(v * 2 + 1, vl, vm, l, r);
  modify(v * 2 + 2, vm + 1, vr, l, r);
  t[v] = unite(t[v * 2 + 1], t[v * 2 + 2]);
}
node query(int v, int vl, int vr, int l, int r) {
  push(v, vl, vr);
  if (vl > r || vr < l) {
    return node();
  }
  if (l <= vl && vr <= r) {
    return t[v];
  }
  int vm = (vl + vr) >> 1;
  node q1 = query(v * 2 + 1, vl, vm, l, r);
  node q2 = query(v * 2 + 2, vm + 1, vr, l, r);
  return unite(q1, q2);
}
void print(int v, int vl, int vr) {
  push(v, vl, vr);
  if (vl == vr) {
    cout << t[v].sum << " ";
    return;
  }
  int vm = (vl + vr) >> 1;
  print(v * 2 + 1, vl, vm);
  print(v * 2 + 2, vm + 1, vr);
}
int main() {
  n = read();
  m = read();
  string second = readStr();
  for (int i = 0; i < n; i++) {
    a[i] = second[i] == '>' ? 0 : 1;
  }
  build(0, 0, n - 1);
  for (int i = 0; i < m; i++) {
    int l = read() - 1, r = read() - 1;
    modify(0, 0, n - 1, l, r);
    node res = query(0, 0, n - 1, l, r);
    cout << max(res.seg01, max(res.seg0, res.seg1)) << "\n";
  }
  return 0;
}