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 int MX = 500005;
struct Node {
  int mx;
  int pa, pb;
  int sa, sb;
  int len;
} st1[4 * MX], st2[4 * MX];
int lz[4 * MX];
Node operator+(const Node &a, const Node &b) {
  Node r = {0, 0, 0, 0, 0, 0};
  r.len = a.len + b.len;
  int cen = 0;
  if (!a.sb && !b.pa)
    cen = a.sa + b.pb;
  else if (!a.sb)
    cen = a.sa + b.pa + b.pb;
  else if (!b.pa)
    cen = a.sa + a.sb + b.pb;
  r.mx = max({a.mx, b.mx, cen});
  r.pa = a.pa;
  r.pb = a.pb;
  if (a.pa + a.pb == a.len) {
    if (!b.pa)
      r.pb += b.pb;
    else if (!a.pb) {
      r.pa += b.pa;
      r.pb += b.pb;
    }
  }
  r.sa = b.sa;
  r.sb = b.sb;
  if (b.sa + b.sb == b.len) {
    if (!a.sb)
      r.sa += a.sa;
    else if (!b.sa) {
      r.sa += a.sa;
      r.sb += a.sb;
    }
  }
  return r;
}
void build(int i, int j, int pos, char a[]) {
  st1[pos].len = st2[pos].len = j - i + 1;
  if (i == j) {
    if (a[i] == '>') {
      st1[pos].mx = 1;
      st1[pos].pa = st1[pos].sa = 1;
      st1[pos].pb = st1[pos].sb = 0;
      st2[pos].mx = 1;
      st2[pos].pa = st2[pos].sa = 0;
      st2[pos].pb = st2[pos].sb = 1;
    } else {
      st1[pos].mx = 1;
      st1[pos].pa = st1[pos].sa = 0;
      st1[pos].pb = st1[pos].sb = 1;
      st2[pos].mx = 1;
      st2[pos].pa = st2[pos].sa = 1;
      st2[pos].pb = st2[pos].sb = 0;
    }
    return;
  }
  int m = (i + j) / 2;
  build(i, m, pos * 2, a);
  build(m + 1, j, pos * 2 + 1, a);
  st1[pos] = st1[pos * 2] + st1[pos * 2 + 1];
  st2[pos] = st2[pos * 2] + st2[pos * 2 + 1];
}
void push(int i, int j, int pos) {
  if (i < j) {
    lz[pos * 2] ^= lz[pos];
    lz[pos * 2 + 1] ^= lz[pos];
  }
  swap(st1[pos], st2[pos]);
  lz[pos] = 0;
}
Node update(int i, int j, int pos, int a, int b) {
  if (lz[pos]) push(i, j, pos);
  if (b < i || j < a) return {0, 0, 0, 0, 0, 0};
  if (a <= i && j <= b) {
    lz[pos] = 1;
    push(i, j, pos);
    return st1[pos];
  }
  int m = (i + j) / 2;
  Node r = update(i, m, pos * 2, a, b) + update(m + 1, j, pos * 2 + 1, a, b);
  st1[pos] = st1[pos * 2] + st1[pos * 2 + 1];
  st2[pos] = st2[pos * 2] + st2[pos * 2 + 1];
  return r;
}
int n, q;
char a[MX];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> q;
  for (int i = 1; i <= n; i++) cin >> a[i];
  build(1, n, 1, a);
  while (q--) {
    int l, r;
    cin >> l >> r;
    cout << update(1, n, 1, l, r).mx << '\n';
  }
  return 0;
}