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;
struct T {
  int lz, sz;
  int v[2], t[2], f1[2], f2[2];
  T(int x = 1) {
    lz = 0, sz = x;
    for (int i = 0; i < 2; i++) {
      v[i] = f1[i] = x;
      t[i] = f2[i] = 0;
    }
  }
  void upd() {
    for (int i = 0; i < 2; i++) t[i] ^= 1;
    swap(v[0], v[1]);
    lz ^= 1;
  }
  friend T operator+(T l, T r) {
    T ret(0);
    T c[2] = {l, r};
    int first = 0, g = 0;
    for (int i = 0; i < 2; i++) {
      first += c[i].f1[!i];
      g ^= c[i].t[!i];
      ret.sz += c[i].sz;
      ret.t[i] = c[i].t[i];
      if (c[i].f1[i] == c[i].sz) {
        if (c[i].t[i] == c[!i].t[i]) {
          ret.f1[i] = c[i].f1[i] + c[!i].f1[i];
          ret.f2[i] = c[!i].f2[i];
        } else {
          ret.f1[i] = c[i].f1[i];
          ret.f2[i] = c[!i].f1[i];
        }
      } else {
        ret.f1[i] = c[i].f1[i];
        ret.f2[i] = c[i].f2[i];
        ret.f2[i] +=
            (ret.f1[i] + ret.f2[i] == c[i].sz && c[i].t[i] != c[!i].t[i]) *
            c[!i].f1[i];
      }
      for (int j = 0; j < 2; j++)
        ret.v[j] = max({ret.v[j], ret.f1[i], ret.f2[i], c[i].v[j]});
    }
    if (g) {
      ret.v[c[0].t[1]] = max(ret.v[c[0].t[1]], first);
    } else {
      for (int i = 0; i < 2; i++) {
        int j = !i ^ c[i].t[!i];
        ret.v[j] = max(ret.v[j], first + c[i].f2[!i]);
      }
    }
    return ret;
  }
};
struct segTree {
  int l, r;
  segTree *c[2];
  T val;
  segTree(int a, int b) {
    l = a, r = b;
    val.sz = r - l + 1;
    if (l != r) {
      int mid = (l + r) / 2;
      c[0] = new segTree(l, mid);
      c[1] = new segTree(mid + 1, r);
      val = c[0]->val + c[1]->val;
    }
  }
  T add(int a, int b) {
    if (b < l || r < a) return T(0);
    if (a <= l && r <= b) {
      val.upd();
      return val;
    }
    T ret[2];
    for (int i = 0; i < 2; i++) {
      if (val.lz) c[i]->val.upd();
      ret[i] = c[i]->add(a, b);
    }
    val = c[0]->val + c[1]->val;
    return ret[0] + ret[1];
  }
};
const int mxn = 500000;
int n, q;
segTree tre(1, mxn);
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> q;
  for (int i = 1; i <= n; i++) {
    char c;
    cin >> c;
    if (c == '<') tre.add(i, i);
  }
  while (q--) {
    int l, r;
    cin >> l >> r;
    cout << tre.add(l, r).v[0] << '\n';
  }
  return 0;
}