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>
const int maxn = 5e5 + 1;
using namespace std;
int n, q;
string s;
struct node {
  int lb = 0, rb = 0, first = 0, second = 0;
  int _lb = 0, _rb = 0, _l = 0, _r = 0;
  int t = 0, _t = 0;
  node() {}
};
node t[4 * maxn];
bool add[4 * maxn];
void rnt(node &tx, node t2x, node t2x1, int cl, int cr, int md) {
  tx.first = t2x.first + (t2x.first == md - cl ? t2x1.first : 0);
  tx.second = t2x1.second + (t2x1.second == cr - md ? t2x.second : 0);
  tx._l = t2x._l + (t2x._l == md - cl ? t2x1._l : 0);
  tx._r = t2x1._r + (t2x1._r == cr - md ? t2x._r : 0);
  tx.lb = (t2x._l == md - cl ? t2x._l + t2x1.lb : t2x.lb);
  tx.lb += (tx.lb == md - cl ? t2x1.first : 0);
  tx.rb = (t2x1._r == cr - md ? t2x1._r + t2x.rb : t2x1.rb);
  tx.rb += (tx.rb == cr - md ? t2x.second : 0);
  tx._lb = (t2x.first == md - cl ? t2x.first + t2x1._lb : t2x._lb);
  tx._lb += (tx._lb == md - cl ? t2x1._l : 0);
  tx._rb = (t2x1.second == cr - md ? t2x1.second + t2x._rb : t2x1._rb);
  tx._rb += (tx._rb == cr - md ? t2x._r : 0);
  tx.t = max(t2x.t, t2x1.t);
  tx.t = max(tx.t, max(tx.first, tx.second));
  tx.t = max(tx.t, tx.lb);
  tx.t = max(tx.t, tx.rb);
  tx.t = max(tx.t, t2x.second + t2x1.lb);
  tx.t = max(tx.t, t2x.rb + t2x1.first);
  tx._t = max(t2x._t, t2x1._t);
  tx._t = max(tx._t, max(tx._l, tx._r));
  tx._t = max(tx._t, tx._lb);
  tx._t = max(tx._t, tx._rb);
  tx._t = max(tx._t, t2x._r + t2x1._lb);
  tx._t = max(tx._t, t2x._rb + t2x1._l);
}
void build(int x, int cl, int cr) {
  if (cr - cl > 1) {
    int md = (cl + cr) / 2;
    build(2 * x, cl, md);
    build(2 * x + 1, md, cr);
    rnt(t[x], t[2 * x], t[2 * x + 1], cl, cr, md);
  } else {
    t[x].lb = t[x].rb = t[x]._lb = t[x]._rb = t[x].t = t[x]._t = 1;
    if (s[cl] == '>')
      t[x].second = t[x]._l = 1;
    else
      t[x]._r = t[x].first = 1;
  }
}
inline void push(int x, int cl, int cr) {
  if (!add[x]) return;
  if (cr - cl > 1) {
    add[2 * x] ^= 1;
    add[2 * x + 1] ^= 1;
  }
  swap(t[x].first, t[x]._l);
  swap(t[x].second, t[x]._r);
  swap(t[x].t, t[x]._t);
  swap(t[x].lb, t[x]._lb);
  swap(t[x].rb, t[x]._rb);
  add[x] = 0;
}
void upd(int x, int cl, int cr, int first, int second) {
  push(x, cl, cr);
  if (second <= cl || cr <= first) return;
  if (first <= cl && cr <= second) {
    add[x] = 1;
    push(x, cl, cr);
    return;
  }
  upd(2 * x, cl, (cl + cr) / 2, first, second);
  upd(2 * x + 1, (cl + cr) / 2, cr, first, second);
  rnt(t[x], t[2 * x], t[2 * x + 1], cl, cr, (cl + cr) / 2);
}
node get(int x, int cl, int cr, int first, int second) {
  push(x, cl, cr);
  node ans;
  if (second <= cl || cr <= first) return ans;
  if (first <= cl && cr <= second) {
    return t[x];
  }
  int md = (cl + cr) / 2;
  node ll = get(2 * x, cl, md, first, second);
  node rr = get(2 * x + 1, md, cr, first, second);
  rnt(ans, ll, rr, max(first, cl), min(cr, second), md);
  return ans;
}
string tt;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q >> s;
  tt = s;
  build(1, 0, n);
  for (int i = 0; i < q; i++) {
    int first, second;
    cin >> first >> second;
    --first;
    upd(1, 0, n, first, second);
    int cx = get(1, 0, n, first, second).t;
    cout << cx << '\n';
  }
  return 0;
}