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;
template <typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
const int N = 5e5 + 5;
struct node {
  int LR, RL, preL, preR, preLR, preRL, sufL, sufR, sufLR, sufRL, len;
  node() {
    LR = RL = preL = preR = preLR = preRL = sufL = sufR = sufLR = sufRL = len =
        0;
  }
  void swp() {
    swap(LR, RL);
    swap(preL, preR);
    swap(preLR, preRL);
    swap(sufL, sufR);
    swap(sufLR, sufRL);
  }
  node(char c) {
    LR = RL = 1;
    preL = 1;
    preR = 0;
    sufL = 1;
    sufR = 0;
    preLR = preRL = sufLR = sufRL = 1;
    if (c == '>') swp();
    len = 1;
  }
  node operator+(const node &o) const {
    if (len == 0) return o;
    if (o.len == 0) return *this;
    node x;
    x.preL = (preL == len ? len + o.preL : preL);
    x.preR = (preR == len ? len + o.preR : preR);
    x.sufL = (o.sufL == o.len ? o.len + sufL : o.sufL);
    x.sufR = (o.sufR == o.len ? o.len + sufR : o.sufR);
    x.preLR = (preL == len    ? len + o.preLR
               : preLR == len ? len + o.preR
                              : preLR);
    x.preRL = (preR == len    ? len + o.preRL
               : preRL == len ? len + o.preL
                              : preRL);
    x.sufLR = (o.sufR == o.len    ? o.len + sufLR
               : o.sufLR == o.len ? o.len + sufL
                                  : o.sufLR);
    x.sufRL = (o.sufL == o.len    ? o.len + sufRL
               : o.sufRL == o.len ? o.len + sufR
                                  : o.sufRL);
    x.RL = max({RL, o.RL, sufR + o.preRL, sufRL + o.preL});
    x.LR = max({LR, o.LR, sufL + o.preLR, sufLR + o.preR});
    x.len = len + o.len;
    return x;
  }
};
int n, q;
string s;
node tree[4 * N];
bool lazy[4 * N];
void build(int i, int l, int r) {
  if (l == r) {
    tree[i] = node(s[l]);
    return;
  }
  int m = (l + r) / 2;
  build(2 * i + 1, l, m);
  build(2 * i + 2, m + 1, r);
  tree[i] = tree[2 * i + 1] + tree[2 * i + 2];
}
void prop(int i, int l, int r) {
  if (!lazy[i]) return;
  tree[i].swp();
  if (l < r) {
    lazy[2 * i + 1] ^= 1;
    lazy[2 * i + 2] ^= 1;
  }
  lazy[i] = false;
}
void upd(int i, int l, int r, int L, int R) {
  prop(i, l, r);
  if (r < L || R < l) return;
  if (L <= l && r <= R) {
    lazy[i] ^= 1;
    prop(i, l, r);
    return;
  }
  int m = (l + r) / 2;
  upd(2 * i + 1, l, m, L, R);
  upd(2 * i + 2, m + 1, r, L, R);
  tree[i] = tree[2 * i + 1] + tree[2 * i + 2];
}
node query(int i, int l, int r, int L, int R) {
  if (r < L || R < l) return node();
  prop(i, l, r);
  if (L <= l && r <= R) return tree[i];
  int m = (l + r) / 2;
  return query(2 * i + 1, l, m, L, R) + query(2 * i + 2, m + 1, r, L, R);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> q >> s;
  build(0, 0, n - 1);
  while (q--) {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    upd(0, 0, n - 1, l, r);
    cout << query(0, 0, n - 1, l, r).RL << '\n';
  }
}