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;
std::mt19937 rnd(
    (int)std::chrono::steady_clock::now().time_since_epoch().count());
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 500000;
const int MAXQ = 100000;
const int MAXS = 4 * MAXN;
struct Val {
  int sz, prefl, prefr, suffl, suffr, preflr, prefrl, sufflr, suffrl, insidelr,
      insiderl;
};
int n, nq;
char s[MAXN + 1];
int ql[MAXQ], qr[MAXQ], qans[MAXQ];
Val smake(char c) {
  Val ret;
  ret.sz = 1, ret.preflr = ret.prefrl = ret.sufflr = ret.suffrl = ret.insidelr =
                  ret.insiderl = 1;
  if (c == '<')
    ret.prefl = 1, ret.prefr = 0, ret.suffl = 1, ret.suffr = 0;
  else if (c == '>')
    ret.prefl = 0, ret.prefr = 1, ret.suffl = 0, ret.suffr = 1;
  else
    assert(false);
  return ret;
}
Val smerge(const Val& a, const Val& b) {
  Val ret;
  ret.sz = a.sz + b.sz;
  ret.prefl = a.prefl + (a.prefl == a.sz ? b.prefl : 0);
  ret.prefr = a.prefr + (a.prefr == a.sz ? b.prefr : 0);
  ret.suffl = b.suffl + (b.suffl == b.sz ? a.suffl : 0);
  ret.suffr = b.suffr + (b.suffr == b.sz ? a.suffr : 0);
  ret.preflr =
      a.preflr + (a.preflr == a.sz ? a.prefl == a.sz ? b.preflr : b.prefr : 0);
  ret.prefrl =
      a.prefrl + (a.prefrl == a.sz ? a.prefr == a.sz ? b.prefrl : b.prefl : 0);
  ret.sufflr =
      b.sufflr + (b.sufflr == b.sz ? b.suffr == b.sz ? a.sufflr : a.suffl : 0);
  ret.suffrl =
      b.suffrl + (b.suffrl == b.sz ? b.suffl == b.sz ? a.suffrl : a.suffr : 0);
  ret.insidelr = max(max(a.insidelr, b.insidelr),
                     max(a.sufflr + b.prefr, a.suffl + b.preflr));
  ret.insiderl = max(max(a.insiderl, b.insiderl),
                     max(a.suffrl + b.prefl, a.suffr + b.prefrl));
  return ret;
}
void sinvert(Val& a) {
  swap(a.prefl, a.prefr);
  swap(a.suffl, a.suffr);
  swap(a.preflr, a.prefrl);
  swap(a.sufflr, a.suffrl);
  swap(a.insidelr, a.insiderl);
}
bool slazy[MAXS];
Val sval[MAXS];
void sapply(int x) {
  sinvert(sval[x]);
  slazy[x] = !slazy[x];
}
void spush(int x) {
  if (slazy[x]) sapply(2 * x + 1), sapply(2 * x + 2), slazy[x] = false;
}
void spull(int x) { sval[x] = smerge(sval[2 * x + 1], sval[2 * x + 2]); }
void sinit(int x, int l, int r) {
  slazy[x] = false;
  if (l == r) {
    sval[x] = smake(s[l]);
  } else {
    int m = l + (r - l) / 2;
    sinit(2 * x + 1, l, m);
    sinit(2 * x + 2, m + 1, r);
    spull(x);
  }
}
void stoggle(int x, int l, int r, int L, int R) {
  if (L <= l && r <= R) {
    sapply(x);
  } else {
    int m = l + (r - l) / 2;
    spush(x);
    if (L <= m) stoggle(2 * x + 1, l, m, L, R);
    if (m + 1 <= R) stoggle(2 * x + 2, m + 1, r, L, R);
    spull(x);
  }
}
Val sget(int x, int l, int r, int L, int R) {
  if (L <= l && r <= R) {
    return sval[x];
  } else {
    int m = l + (r - l) / 2;
    spush(x);
    if (L > m) return sget(2 * x + 2, m + 1, r, L, R);
    if (m + 1 > R) return sget(2 * x + 1, l, m, L, R);
    return smerge(sget(2 * x + 1, l, m, L, R), sget(2 * x + 2, m + 1, r, L, R));
  }
}
void solve() {
  sinit(0, 0, n - 1);
  for (int i = (0); i < (nq); ++i) {
    int l = ql[i], r = qr[i];
    stoggle(0, 0, n - 1, l, r);
    Val val = sget(0, 0, n - 1, l, r);
    qans[i] = val.insiderl;
  }
}
void run() {
  scanf("%d%d", &n, &nq);
  scanf("%s", s);
  assert(strlen(s) == n);
  for (int i = (0); i < (nq); ++i)
    scanf("%d%d", &ql[i], &qr[i]), --ql[i], --qr[i];
  solve();
  for (int i = (0); i < (nq); ++i) printf("%d\n", qans[i]);
}
int main() {
  run();
  return 0;
}