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;
long long n;
bitset<500069> a;
struct val {
  long long mx = 0, c[2] = {0, 0};
  bool ft[2] = {1, 1}, jd = 1;
} v0;
struct segtree {
  long long l, r;
  val ans[2];
  bool lz;
  segtree *p[2];
  val mrg(val x, val y) {
    if (x.mx && y.mx) {
      long long w;
      val z;
      z.mx = max(x.mx, y.mx);
      z.c[0] = x.c[0];
      z.c[1] = y.c[1];
      z.ft[0] = x.ft[0];
      z.ft[1] = y.ft[1];
      z.jd = 0;
      if (x.ft[1] || y.ft[0]) {
        w = x.c[1] + y.c[0];
        z.mx = max(z.mx, w);
        if (x.jd) {
          z.c[0] = w;
        }
        if (y.jd) {
          z.c[1] = w;
        }
        z.jd = x.jd && y.jd;
      }
      return z;
    } else if (!x.mx) {
      return y;
    } else {
      return x;
    }
  }
  void bd(long long lh, long long rh) {
    l = lh;
    r = rh;
    lz = 0;
    if (l == r) {
      long long ii, jj;
      for (ii = 0; ii < 2; ii++) {
        ans[ii].mx = 1;
        for (jj = 0; jj < 2; jj++) {
          ans[ii].c[jj] = 1;
        }
        ans[ii].ft[!a[l] ^ ii] = 0;
      }
    } else {
      long long ii, md = (l + r) / 2;
      for (ii = 0; ii < 2; ii++) {
        p[ii] = new segtree;
        p[ii]->bd(!ii ? l : md + 1, !ii ? md : r);
      }
      for (ii = 0; ii < 2; ii++) {
        ans[ii] = mrg(p[0]->ans[ii], p[1]->ans[ii]);
      }
    }
  }
  void blc() {
    if (lz) {
      long long ii;
      for (ii = 0; ii < 2; ii++) {
        swap(p[ii]->ans[0], p[ii]->ans[1]);
        p[ii]->lz ^= 1;
      }
      lz = 0;
    }
  }
  val qr(long long lh, long long rh) {
    if (l > rh || r < lh) {
      return v0;
    } else if (l >= lh && r <= rh) {
      swap(ans[0], ans[1]);
      lz ^= 1;
      return ans[0];
    } else {
      long long ii;
      val tmp;
      blc();
      tmp = mrg(p[0]->qr(lh, rh), p[1]->qr(lh, rh));
      for (ii = 0; ii < 2; ii++) {
        ans[ii] = mrg(p[0]->ans[ii], p[1]->ans[ii]);
      }
      return tmp;
    }
  }
} sg;
int main() {
  long long t, rr, i, k, l;
  char ch;
  scanf("%lld%lld", &n, &t);
  for (i = 1; i <= n; i++) {
    scanf(" %c", &ch);
    a[i] = ch == '>';
  }
  sg.bd(1, n);
  for (rr = 0; rr < t; rr++) {
    scanf("%lld%lld", &k, &l);
    printf("%lld\n", sg.qr(k, l).mx);
  }
}