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>
template <typename T>
bool ckmax(T& a, T b) {
  return a < b ? a = b, 1 : 0;
}
const int MN = 5e5 + 10;
int N, Q, cL;
char s[MN];
struct range {
 public:
  int l[2], m[2], r[2];
  bool z;
  void set(bool v) {
    m[0] = m[1] = 1;
    if (v) {
      r[0] = 1, l[0] = -1;
      l[1] = 1, r[1] = -1;
    } else {
      l[0] = 1, r[0] = -1;
      r[1] = 1, l[1] = -1;
    }
    z = 0;
  }
  void flip() {
    z ^= 1;
    std::swap(l[0], l[1]);
    std::swap(m[0], m[1]);
    std::swap(r[0], r[1]);
  }
} st[1 << 20], cur;
range merge(const range& l, int L, const range& r, int R) {
  range n;
  n.z = 0;
  for (int i = 0; i < 2; ++i) {
    if (l.l[i] > 0)
      n.l[i] = l.l[i] + (l.l[i] == L && r.l[i] > 0 ? r.l[i] : 0);
    else {
      n.l[i] = l.l[i];
      if (l.l[i] == -L)
        if (r.l[i] > 0 || l.r[i] == L) n.l[i] -= std::abs(r.l[i]);
    }
    if (r.r[i] > 0)
      n.r[i] = r.r[i] + (r.r[i] == R && l.r[i] > 0 ? l.r[i] : 0);
    else {
      n.r[i] = r.r[i];
      if (r.r[i] == -R)
        if (l.r[i] > 0 || r.l[i] == R) n.r[i] -= std::abs(l.r[i]);
    }
    n.m[i] = std::max(l.m[i], r.m[i]);
    if (l.r[i] > 0 || r.l[i] > 0)
      ckmax(n.m[i], std::abs(l.r[i]) + std::abs(r.l[i]));
  }
  return n;
}
void down(int n) {
  if (st[n].z) {
    st[n << 1].flip();
    st[n << 1 | 1].flip();
    st[n].z = 0;
  }
}
void build(int n, int l, int r) {
  if (r - l > 1) {
    int m = l + (r - l) / 2;
    down(n);
    build(n << 1, l, m);
    build(n << 1 | 1, m, r);
    st[n] = merge(st[n << 1], m - l, st[n << 1 | 1], r - m);
  } else
    st[n].set(s[l] == '>');
}
void upd(int n, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr) {
    st[n].flip();
    if (cL)
      cur = merge(cur, cL, st[n], r - l);
    else
      cur = st[n];
    cL += r - l;
  } else {
    int m = l + (r - l) / 2;
    down(n);
    if (ql < m) upd(n << 1, l, m, ql, qr);
    if (m < qr) upd(n << 1 | 1, m, r, ql, qr);
    st[n] = merge(st[n << 1], m - l, st[n << 1 | 1], r - m);
  }
}
int main() {
  scanf("%d%d", &N, &Q);
  scanf(" %s", s);
  build(1, 0, N);
  for (int i = 0, l, r; i < Q; ++i) {
    scanf("%d%d", &l, &r), --l;
    upd(1, 0, N, l, r);
    printf("%d\n", cur.m[0]);
    cL = 0;
  }
  return 0;
}