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 GCC optimize("Ofast", "unroll-loops", "omit-frame-pointer", "inline")
#pragma GCC option("arch=native", "tune=native", "no-zero-upper")
#pragma GCC target("avx2")
using namespace std;
struct info {
  int m;
  int lt, lm;
  int rt, rm;
  info() : m(0), lt(0), lm(0), rt(0), rm(0) {}
};
struct node {
  info ok, inv;
  bool lazy;
  node() : lazy(0) {}
};
node st[4 * (long long)(5e5 + 5)];
string second;
int n, q;
info join(info &l, info &r, int szl, int szr) {
  int m = max(l.m, r.m);
  int lt = l.lt;
  int lm = l.lm;
  int rt = r.rt;
  int rm = r.rm;
  if (l.rt == r.lt || (!l.rt && r.lt == 1)) {
    m = max(m, l.rm + r.lm);
    if (lm == szl) lm = l.rm + r.lm;
    if (rm == szr) rm = l.rm + r.lm;
  }
  info res;
  res.m = m;
  res.rm = rm;
  res.lm = lm;
  res.lt = lt;
  res.rt = rt;
  return res;
}
node merge(node &l, node &r, int szl, int szr) {
  node res;
  res.ok = join(l.ok, r.ok, szl, szr);
  res.inv = join(l.inv, r.inv, szl, szr);
  return res;
}
void build(int p, int l, int r) {
  if (l == r) {
    int t = 1;
    if (second[l] == '>') t = 0;
    info ok;
    ok.m = 1;
    ok.lt = t;
    ok.rt = t;
    ok.lm = 1;
    ok.rm = 1;
    info inv = ok;
    inv.lt = inv.rt = 1 - t;
    st[p].ok = ok;
    st[p].inv = inv;
    return;
  }
  int mid = (l + r) >> 1;
  build(p << 1, l, mid);
  build((p << 1) + 1, mid + 1, r);
  st[p] = merge(st[p << 1], st[(p << 1) + 1], mid - l + 1, r - mid);
}
void app(int p) {
  swap(st[p].ok, st[p].inv);
  st[p].lazy ^= 1;
}
void push(int p, int l, int r) {
  if (l == r || !st[p].lazy) return;
  app(p << 1);
  app((p << 1) + 1);
  st[p].lazy = 0;
}
void update(int p, int l, int r, int L, int R) {
  push(p, l, r);
  if (L <= l && r <= R) {
    app(p);
    return;
  }
  int mid = (l + r) >> 1;
  if (L <= mid) update(p << 1, l, mid, L, R);
  if (R > mid) update((p << 1) + 1, mid + 1, r, L, R);
  st[p] = merge(st[p << 1], st[(p << 1) + 1], mid - l + 1, r - mid);
}
node query(int p, int l, int r, int L, int R) {
  push(p, l, r);
  if (L <= l && r <= R) return st[p];
  int mid = (l + r) >> 1;
  if (R <= mid) return query(p << 1, l, mid, L, R);
  if (L > mid) return query((p << 1) + 1, mid + 1, r, L, R);
  node a = query(p << 1, l, mid, L, R);
  node b = query((p << 1) + 1, mid + 1, r, L, R);
  return merge(a, b, mid - l + 1, r - mid);
}
void qq(int l, int r) {
  update(1, 0, n - 1, l, r);
  node x = query(1, 0, n - 1, l, r);
  cout << (x.ok.m) << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> q;
  cin >> second;
  build(1, 0, n - 1);
  while (q--) {
    int l, r;
    cin >> l >> r;
    l--, r--;
    qq(l, r);
  }
  return 0;
}