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 optimize("unroll-loops")
const long long INF = 0x3f3f3f3f3f3f3f3f;
const long long llinf = (1LL << 60);
const int inf = (1 << 30);
const int nmax = 5e5 + 50;
const long long mod = 1e9 + 7;
using namespace std;
int n, q, l, r, i;
char c[nmax];
struct nod {
  int x00, x01, x10, x11, mx1, mx2, rs, l, t, y00, y01, y10, y11;
  nod() {
    this->x00 = this->x01 = this->x10 = this->x11 = this->y00 = this->y01 =
        this->y10 = this->y11 = this->mx1 = this->mx2 = this->rs = this->l =
            this->t = 0;
  }
} st[4 * nmax], f, s, e;
nod merge(nod x, nod y) {
  if (!x.t) return y;
  if (!y.t) return x;
  nod z = e;
  z.t = x.t + y.t;
  z.x00 = x.x00, z.x01 = x.x01, z.x10 = y.x10, z.x11 = y.x11;
  z.y00 = x.y00, z.y01 = x.y01, z.y10 = y.y10, z.y11 = y.y11;
  if (x.x00 == x.t) z.x00 += y.x00;
  if (x.x01 == x.t) z.x01 += y.x01;
  if (y.x10 == y.t) z.x10 += x.x10;
  if (y.x11 == y.t) z.x11 += x.x11;
  z.rs = max(x.rs, y.rs);
  z.rs = max(max(z.x00, z.x01), max(z.x10, z.x11));
  z.rs = max(z.rs, max(x.x10 + y.x00, x.x11 + y.x01));
  z.mx1 = max(x.mx1, y.mx1), z.mx2 = max(x.mx2, y.mx2);
  if (x.y00 == x.t)
    z.y00 += y.x01;
  else if (x.x00 == x.t && (y.x01 || y.y00))
    z.y00 = x.x00 + max(y.x01, y.y00);
  if (x.y01 == x.t)
    z.y01 += y.x00;
  else if (x.x01 == x.t && (y.x00 || y.y01))
    z.y01 = x.x01 + max(y.x00, y.y01);
  if (y.y10 == y.t)
    z.y10 += x.x10;
  else if (y.x11 == y.t && (x.x10 || x.y10))
    z.y10 = y.x11 + max(x.x10, x.y10);
  if (y.y11 == y.t)
    z.y11 += x.x11;
  else if (y.x10 == y.t && (x.x11 || x.y11))
    z.y11 = y.x10 + max(x.x11, x.y11);
  if (x.y10) z.mx1 = max(z.mx1, x.y10 + y.x01);
  if (y.y00) z.mx1 = max(z.mx1, y.y00 + x.x10);
  if (x.y11) z.mx2 = max(z.mx2, x.y11 + y.x00);
  if (y.y01) z.mx2 = max(z.mx2, y.y01 + x.x11);
  z.mx1 = max(z.mx1, max(z.y00, z.y10));
  z.mx2 = max(z.mx2, max(z.y01, z.y11));
  if (x.x10 && y.x01) z.mx1 = max(z.mx1, x.x10 + y.x01);
  if (x.x11 && y.x00) z.mx2 = max(z.mx2, x.x11 + y.x00);
  return z;
}
void build(int x, int l, int r) {
  if (l == r) {
    if (c[l] == '>')
      st[x] = f;
    else
      st[x] = s;
    return;
  }
  int mid = (l + r) / 2;
  build(2 * x, l, mid);
  build(2 * x + 1, mid + 1, r);
  st[x] = merge(st[2 * x], st[2 * x + 1]);
}
void push(int x, int l, int r) {
  if (!st[x].l) return;
  swap(st[x].x00, st[x].x01), swap(st[x].y00, st[x].y01),
      swap(st[x].x10, st[x].x11), swap(st[x].y10, st[x].y11),
      swap(st[x].mx1, st[x].mx2);
  if (l != r) {
    st[2 * x].l ^= 1;
    st[2 * x + 1].l ^= 1;
  }
  st[x].l = 0;
}
void upd(int x, int l, int r, int tl, int tr) {
  push(x, l, r);
  if (tl <= l && r <= tr) {
    st[x].l ^= 1;
    push(x, l, r);
    return;
  }
  int mid = (l + r) / 2;
  if (tl <= mid) upd(x * 2, l, mid, tl, tr);
  if (mid < tr) upd(x * 2 + 1, mid + 1, r, tl, tr);
  push(x * 2, l, mid);
  push(x * 2 + 1, mid + 1, r);
  st[x] = merge(st[x * 2], st[x * 2 + 1]);
}
nod qry(int x, int l, int r, int tl, int tr) {
  push(x, l, r);
  if (l > tr || r < tl) return e;
  if (tl <= l && r <= tr) return st[x];
  int mid = (l + r) / 2;
  return merge(qry(x * 2, l, mid, tl, tr), qry(x * 2 + 1, mid + 1, r, tl, tr));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cerr.tie(0);
  cout.tie(0);
  cin >> n >> q;
  for (i = 1; i <= n; i++) cin >> c[i];
  f.x00 = f.x10 = s.x01 = s.x11 = f.rs = s.rs = f.t = s.t = 1;
  build(1, 1, n);
  while (q--) {
    cin >> l >> r;
    upd(1, 1, n, l, r);
    nod o = qry(1, 1, n, l, r);
    cout << max(o.rs, o.mx1) << '\n';
  }
  return 0;
}