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(2)
using namespace std;
const int N = 5e5 + 5;
template <class o>
void qr(o &x) {
  x = 0;
  char c = getchar();
  int f = 1;
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + (c ^ 48);
    c = getchar();
  }
  x *= f;
}
template <class o>
void qw(o x) {
  if (x < 0) putchar('-'), x = -x;
  if (x / 10) qw(x / 10);
  putchar(x % 10 + 48);
}
struct SGT {
  int l[2], m[2], r[2], S;
  bool rv;
  inline void set(bool v) {
    m[0] = m[1] = 1;
    S = 1;
    rv = 0;
    if (v)
      r[0] = 1, l[0] = -1, r[1] = -1, l[1] = 1;
    else
      r[1] = 1, l[1] = -1, r[0] = -1, l[0] = 1;
  }
  inline void rev() {
    swap(l[0], l[1]);
    swap(m[0], m[1]);
    swap(r[0], r[1]);
    rv ^= 1;
  }
  friend SGT operator+(const SGT &l, const SGT &r) {
    SGT n;
    n.S = l.S + r.S;
    int L = l.S, R = r.S;
    n.rv = 0;
    for (int i = 0; i < 2; i++) {
      n.l[i] = l.l[i];
      n.r[i] = r.r[i];
      if (l.l[i] > 0)
        n.l[i] += (l.l[i] == L && r.l[i] > 0 ? r.l[i] : 0);
      else if (l.l[i] == -L)
        if (l.r[i] == L || r.l[i] > 0) n.l[i] -= abs(r.l[i]);
      if (r.r[i] > 0)
        n.r[i] += (r.r[i] == R && l.r[i] > 0 ? l.r[i] : 0);
      else if (r.r[i] == -R)
        if (r.l[i] == R || l.r[i] > 0) n.r[i] -= abs(l.r[i]);
      n.m[i] = max(l.m[i], r.m[i]);
      if (l.r[i] > 0 || r.l[i] > 0)
        n.m[i] = max(n.m[i], abs(l.r[i]) + abs(r.l[i]));
    }
    return n;
  }
} t[N << 2], cur;
char s[N];
int cl = 0;
void pushdown(int p) {
  if (t[p].rv) {
    t[p << 1].rev();
    t[p << 1 | 1].rev();
    t[p].rv = 0;
  }
}
void build(int p, int l, int r) {
  t[p].S = r - l + 1;
  if (l == r) {
    t[p].set(s[l] == '>');
    return;
  }
  int mid = l + r >> 1;
  build(p << 1, l, mid);
  build(p << 1 | 1, mid + 1, r);
  t[p] = t[p << 1] + t[p << 1 | 1];
}
void upd(int p, int l, int r, int ql, int qr) {
  if (ql <= l && qr >= r) {
    t[p].rev();
    if (cl)
      cur = cur + t[p];
    else
      cur = t[p];
    ++cl;
    return;
  }
  int mid = l + r >> 1;
  pushdown(p);
  if (ql <= mid) upd(p << 1, l, mid, ql, qr);
  if (qr > mid) upd(p << 1 | 1, mid + 1, r, ql, qr);
  t[p] = t[p << 1] + t[p << 1 | 1];
}
int main() {
  int n, m;
  qr(n), qr(m);
  scanf("%s", s + 1);
  build(1, 1, n);
  for (int i = 1; i <= m; i++) {
    int l, r;
    qr(l), qr(r);
    upd(1, 1, n, l, r);
    cl = 0;
    qw(cur.m[0]);
    puts("");
  }
  return 0;
}