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;
using ll = long long;
class seg {
 private:
  char ldir, rdir;
  int llen, rlen;
  int ma;
  bool block;

 public:
  seg() { ma = -1; }
  seg(char x) {
    ldir = rdir = x;
    llen = rlen = 1;
    ma = 1;
    block = false;
  }
  static char opp(char d) {
    if (d == '<') return '>';
    return '<';
  }
  seg operator+(const seg& o) {
    if (ma == -1) return o;
    if (o.ma == -1) return *this;
    seg nseg;
    nseg.ldir = ldir;
    nseg.rdir = o.rdir;
    nseg.llen = llen;
    nseg.rlen = o.rlen;
    nseg.ma = max(ma, o.ma);
    nseg.block = block | o.block;
    if (rdir == '<' && o.ldir == '>')
      nseg.block = true;
    else {
      if (!block) nseg.llen += o.llen;
      if (!o.block) nseg.rlen += rlen;
      nseg.ma = max(nseg.ma, rlen + o.llen);
    }
    return nseg;
  }
  int get_ma() { return ma; }
};
int n, q;
string s;
vector<pair<seg, seg> > t;
vector<bool> u;
void build(int v, int tl, int tr) {
  if (tl == tr)
    t[v] = make_pair(s[tl], seg::opp(s[tl]));
  else {
    int tm = (tl + tr) >> 1;
    build(v << 1, tl, tm);
    build((v << 1) + 1, tm + 1, tr);
    t[v] = make_pair(t[v << 1].first + t[(v << 1) + 1].first,
                     t[v << 1].second + t[(v << 1) + 1].second);
  }
}
void push(int v, int tl, int tr) {
  if (u[v]) {
    swap(t[v].first, t[v].second);
    u[v] = false;
    if (tl < tr) {
      u[v << 1] = !u[v << 1];
      u[(v << 1) + 1] = !u[(v << 1) + 1];
    }
  }
}
void opp(int v, int tl, int tr, int l, int r) {
  if (l > r) return;
  push(v, tl, tr);
  if (tl > r || l > tr) return;
  if (l <= tl && tr <= r) {
    u[v] = !u[v];
    push(v, tl, tr);
    return;
  }
  int tm = (tl + tr) >> 1;
  opp(v << 1, tl, tm, l, r);
  opp((v << 1) + 1, tm + 1, tr, l, r);
  t[v] = make_pair(t[v << 1].first + t[(v << 1) + 1].first,
                   t[v << 1].second + t[(v << 1) + 1].second);
}
seg cs(int v, int tl, int tr, int l, int r) {
  if (l > r) return seg();
  push(v, tl, tr);
  if (l > tr || tl > r) return seg();
  if (l <= tl && tr <= r) return t[v].first;
  int tm = (tl + tr) >> 1;
  return cs(v << 1, tl, tm, l, r) + cs((v << 1) + 1, tm + 1, tr, l, r);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> q >> s;
  t.assign(4 * n + 10, make_pair(seg(), seg()));
  build(1, 0, n - 1);
  u.assign(4 * n + 10, false);
  while (q--) {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    opp(1, 0, n - 1, l, r);
    cout << cs(1, 0, n - 1, l, r).get_ma() << '\n';
  }
  return 0;
}