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 long long MOD = (long long)1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;
long long fac[1] = {1}, inv[1] = {1};
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long mp(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = ret * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return ret;
}
long long cmb(long long r, long long c) {
  return fac[r] * inv[c] % MOD * inv[r - c] % MOD;
}
priority_queue<int, vector<int>, greater<int>> pq;
vector<int> v;
char s[500001];
int szz = 1 << 19;
struct node {
  int lv, lc, slc, rv, rc, src, rotn, mav;
  void debug() {
    printf("%d %d %d %d %d %d %d %d\n", lv, lc, slc, rv, rc, src, rotn, mav);
  }
} tr[2][1 << 20];
int lazy[1 << 20];
node merge(node a, node b) {
  if (a.rotn == -1) return b;
  if (b.rotn == -1) return a;
  node ret = {a.lv,
              a.lc,
              a.slc,
              b.rv,
              b.rc,
              b.src,
              a.rotn + b.rotn - 1,
              max(a.mav, b.mav)};
  if (a.lv == b.lv && a.rotn == 1)
    ret.lc += b.lc, ret.slc = b.slc;
  else if (a.rotn == 1)
    ret.slc = b.lc;
  if (a.rv == b.rv && b.rotn == 1)
    ret.rc += a.rc, ret.src = a.src;
  else if (b.rotn == 1)
    ret.src = a.rc;
  if (a.rv == b.lv) {
    if (a.rv == 0)
      ret.mav = max(ret.mav, b.lc + a.rc + a.src);
    else
      ret.mav = max(ret.mav, b.lc + a.rc + b.slc);
    if (a.rotn == 2) ret.slc = b.lc + a.rc;
    if (b.rotn == 2) ret.src = b.lc + a.rc;
  } else {
    ret.rotn++;
    if (a.rv == 1) ret.mav = max(ret.mav, a.rc + b.lc);
  }
  ret.mav = max(ret.mav, ret.lc);
  ret.mav = max(ret.mav, ret.rc);
  return ret;
}
node find(int i, int l, int r, int le, int ri, int val) {
  val ^= lazy[i];
  if (l > ri || r < le) return {0, 0, 0, 0, 0, 0, -1, 0};
  if (l <= le && ri <= r) {
    lazy[i] ^= 1;
    val ^= 1;
    return tr[val][i];
  }
  node ret = merge(find(i * 2, l, r, le, (le + ri) / 2, val),
                   find(i * 2 + 1, l, r, (le + ri) / 2 + 1, ri, val));
  tr[0][i] = merge(tr[lazy[i * 2]][i * 2], tr[lazy[i * 2 + 1]][i * 2 + 1]);
  tr[1][i] =
      merge(tr[lazy[i * 2] ^ 1][i * 2], tr[lazy[i * 2 + 1] ^ 1][i * 2 + 1]);
  return ret;
}
void init(int i) {
  if (i >= szz) return;
  init(i * 2);
  init(i * 2 + 1);
  tr[0][i] = merge(tr[0][i * 2], tr[0][i * 2 + 1]);
  tr[1][i] = merge(tr[1][i * 2], tr[1][i * 2 + 1]);
}
int main() {
  memset(tr, -1, sizeof(tr));
  int n, m;
  scanf("%d %d", &n, &m);
  scanf("%s", s);
  for (int i = 0; i < n; i++) {
    if (s[i] == '<')
      tr[0][i + szz] = {0, 1, 0, 0, 1, 0, 1, 1};
    else
      tr[0][i + szz] = {1, 1, 0, 1, 1, 0, 1, 1};
    tr[1][i + szz] = tr[0][i + szz];
    tr[1][i + szz].lv ^= 1, tr[1][i + szz].rv ^= 1;
  }
  init(1);
  int a, b;
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &a, &b);
    a--;
    b--;
    printf("%d\n", find(1, a, b, 0, szz - 1, 0).mav);
  }
}