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>
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
using namespace std;
const int N = 5e5 + 5;
const int mod = 1e9 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int INFi = 0x7f7f7f7f;
const int LEVEL = log2(N) + 1;
long long n, q, a[N];
string second;
struct NODE {
  int len, prei, sufi, inc, dec, pred, sufd, first, l;
  NODE() : len(), prei(), sufi(), inc(), dec(), pred(), sufd(), first(), l() {}
  NODE(int v)
      : len(1),
        prei(1),
        sufi(1),
        inc(1),
        dec(1),
        pred(1),
        sufd(1),
        first(v),
        l(v) {}
  void flip() {
    first = 1 - first;
    l = 1 - l;
    swap(prei, pred);
    swap(sufi, sufd);
    swap(inc, dec);
  }
};
NODE tree[4 * N + 8];
bool lazy[4 * N + 8];
NODE combine(NODE a, NODE b) {
  NODE c;
  c.len = a.len + b.len;
  c.first = a.first;
  c.l = b.l;
  c.prei = a.prei;
  c.pred = a.pred;
  if (a.prei == a.len and (1 - a.l) | b.first) c.prei = a.prei + b.prei;
  if (a.pred == a.len and a.l | (1 - b.first)) c.pred = a.pred + b.pred;
  c.sufi = b.sufi;
  c.sufd = b.sufd;
  if (b.sufi == b.len and (1 - a.l) | b.first) c.sufi = a.sufi + b.sufi;
  if (b.sufd == b.len and a.l | (1 - b.first)) c.sufd = a.sufd + b.sufd;
  c.inc = max(a.inc, b.inc);
  c.dec = max(a.dec, b.dec);
  if ((1 - a.l) | b.first) c.inc = max(c.inc, a.sufi + b.prei);
  if (a.l | (1 - b.first)) c.dec = max(c.dec, a.sufd + b.pred);
  return c;
}
void build(int node, int start, int end) {
  if (start == end) {
    tree[node] = NODE(a[start]);
  } else {
    int mid = (start + end) / 2;
    build(2 * node, start, mid);
    build(2 * node + 1, mid + 1, end);
    tree[node] = combine(tree[2 * node], tree[2 * node + 1]);
  }
}
void pushlazy(int start, int end, int node) {
  if (lazy[node] == 0) return;
  tree[node].flip();
  if (start != end) {
    lazy[node * 2] ^= 1;
    lazy[node * 2 + 1] ^= 1;
  }
  lazy[node] = 0;
}
void update(int node, int start, int end, int l, int r) {
  pushlazy(start, end, node);
  if (start > end or start > r or end < l) return;
  if (start >= l and end <= r) {
    lazy[node] ^= 1;
    pushlazy(start, end, node);
    return;
  }
  int mid = (start + end) / 2;
  update(node * 2, start, mid, l, r);
  update(node * 2 + 1, mid + 1, end, l, r);
  tree[node] = combine(tree[2 * node], tree[2 * node + 1]);
}
NODE query(int node, int start, int end, int l, int r) {
  if (start > end or start > r or end < l) return NODE();
  pushlazy(start, end, node);
  if (l <= start and end <= r) {
    return tree[node];
  }
  int mid = (start + end) / 2;
  NODE p1 = query(2 * node, start, mid, l, r);
  NODE p2 = query(2 * node + 1, mid + 1, end, l, r);
  return combine(p1, p2);
}
void solve() {
  cin >> n >> q >> second;
  for (int i = 1; i <= n; i++) {
    a[i] = (second[i - 1] == '<');
  }
  build(1, 1, n);
  for (int i = 1; i <= q; i++) {
    int l, r;
    cin >> l >> r;
    update(1, 1, n, l, r);
    cout << query(1, 1, n, l, r).inc << "\n";
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed;
  cout << setprecision(15);
  ;
  int test = 1;
  for (int i = 1; i <= test; i++) {
    solve();
  }
}