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("O3")
#pragma GCC target("sse4")
using namespace std;
struct seg {
  int sz = 0;
  int closed = 0;
  int open = 0;
  int prel = 0;
  int prer = 0;
  int sufl = 0;
  int sufr = 0;
  int preop = 0;
  int precl = 0;
  int sufop = 0;
  int sufcl = 0;
  bool revc = 0;
};
seg mergeseg(seg a, seg b) {
  seg ans;
  ans.sz = a.sz + b.sz;
  ans.closed = max(a.closed, b.closed);
  ans.closed = max(ans.closed, a.sufcl + b.prel);
  ans.closed = max(ans.closed, a.sufr + b.precl);
  ans.closed = max(ans.closed, a.sufr + b.prel);
  ans.open = max(a.open, b.open);
  ans.open = max(ans.open, a.sufop + b.prer);
  ans.open = max(ans.open, a.sufl + b.preop);
  ans.open = max(ans.open, a.sufl + b.prer);
  ans.prel = a.prel;
  if (a.prel == a.sz) ans.prel += b.prel;
  ans.prer = a.prer;
  if (a.prer == a.sz) ans.prer += b.prer;
  ans.sufl = b.sufl;
  if (b.sufl == b.sz) ans.sufl += a.sufl;
  ans.sufr = b.sufr;
  if (b.sufr == b.sz) ans.sufr += a.sufr;
  ans.preop = a.preop;
  if (a.preop == a.sz) ans.preop += b.prer;
  if (a.sufl == a.sz) {
    ans.preop = max(ans.preop, a.sufl + b.preop);
    ans.preop = max(ans.preop, a.sufl + b.prer);
  }
  ans.precl = a.precl;
  if (a.precl == a.sz) ans.precl += b.prel;
  if (a.sufr == a.sz) {
    ans.precl = max(ans.precl, a.sufr + b.precl);
    ans.precl = max(ans.precl, a.sufr + b.prel);
  }
  ans.sufop = b.sufop;
  if (b.sufop == b.sz) ans.sufop += a.sufl;
  if (b.sufr == b.sz) {
    ans.sufop = max(ans.sufop, a.sufop + b.sufr);
    ans.sufop = max(ans.sufop, a.sufl + b.sufr);
  }
  ans.sufcl = b.sufcl;
  if (b.sufcl == b.sz) ans.sufcl += a.sufr;
  if (b.sufl == b.sz) {
    ans.sufcl = max(ans.sufcl, a.sufcl + b.sufl);
    ans.sufcl = max(ans.sufcl, a.sufr + b.sufl);
  }
  return ans;
}
void rev(seg &a) {
  a.revc = !a.revc;
  swap(a.closed, a.open);
  swap(a.precl, a.preop);
  swap(a.prel, a.prer);
  swap(a.sufcl, a.sufop);
  swap(a.sufl, a.sufr);
}
void create(seg &ans, bool gl) {
  ans.sz = 1;
  if (gl) {
    ans.prel = 1;
    ans.sufl = 1;
  } else {
    ans.prer = 1;
    ans.sufr = 1;
  }
}
int n;
const int large = 5e5 + 1;
seg segtree[4 * large];
void upd(int p, bool gl, int l = 1, int r = n, int pos = 0) {
  if (l == r) {
    create(segtree[pos], gl);
    return;
  }
  int mid = (l + r) / 2;
  if (p <= mid)
    upd(p, gl, l, mid, 2 * pos + 1);
  else
    upd(p, gl, mid + 1, r, 2 * pos + 2);
  segtree[pos] = mergeseg(segtree[2 * pos + 1], segtree[2 * pos + 2]);
}
seg rq(int l, int r, int rl = 1, int rr = n, int pos = 0) {
  if (l == rl && r == rr) return segtree[pos];
  if (segtree[pos].revc) {
    rev(segtree[2 * pos + 1]);
    rev(segtree[2 * pos + 2]);
    segtree[pos].revc = 0;
  }
  int mid = (rl + rr) / 2;
  if (r <= mid)
    return rq(l, r, rl, mid, 2 * pos + 1);
  else if (l > mid)
    return rq(l, r, mid + 1, rr, 2 * pos + 2);
  else
    return mergeseg(rq(l, mid, rl, mid, 2 * pos + 1),
                    rq(mid + 1, r, mid + 1, rr, 2 * pos + 2));
}
int query(int l, int r) {
  seg a = rq(l, r);
  return max(a.closed, max(a.prel, a.sufr));
}
void fl(int l, int r, int rl = 1, int rr = n, int pos = 0) {
  if (l == rl && r == rr) {
    rev(segtree[pos]);
    return;
  }
  if (segtree[pos].revc) {
    rev(segtree[2 * pos + 1]);
    rev(segtree[2 * pos + 2]);
    segtree[pos].revc = 0;
  }
  int mid = (rl + rr) / 2;
  if (r <= mid)
    fl(l, r, rl, mid, 2 * pos + 1);
  else if (l > mid)
    fl(l, r, mid + 1, rr, 2 * pos + 2);
  else {
    fl(l, mid, rl, mid, 2 * pos + 1);
    fl(mid + 1, r, mid + 1, rr, 2 * pos + 2);
  }
  segtree[pos] = mergeseg(segtree[2 * pos + 1], segtree[2 * pos + 2]);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  memset(segtree, 0, sizeof(segtree));
  int q;
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    char a;
    cin >> a;
    if (a == '<')
      upd(i + 1, 1);
    else
      upd(i + 1, 0);
  }
  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    fl(l, r);
    cout << query(l, r) << "\n";
  }
  return 0;
}