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;
struct node {
  node *l, *r;
  int pre, suf, ans;
  int preans, sufans;
  int rpre, rsuf, rans;
  int rpreans, rsufans;
  int tag;
  int a, b;
  node(int _a, int _b) : l(NULL), r(NULL), a(_a), b(_b) {
    pre = suf = ans = 0;
    preans = sufans = 0;
    rpre = rsuf = rans = 0;
    rpreans = rsufans = 0;
    tag = 0;
  }
  void print() {
    printf("pre %d suf %d ans %d\n", pre, suf, ans);
    printf("preans %d sufans %d\n", preans, sufans);
    printf("tag %d\n", tag);
    printf("rpre %d rsuf %d rans %d\n", rpre, rsuf, rans);
    printf("rpreans %d rsufans %d\n", rpreans, rsufans);
  }
} * root;
int pre(node *n, int tag = 0) {
  if (n->tag ^ tag)
    return n->rpre;
  else
    return n->pre;
}
int suf(node *n, int tag = 0) {
  if (n->tag ^ tag)
    return n->rsuf;
  else
    return n->suf;
}
int ans(node *n, int tag = 0) {
  if (n->tag ^ tag)
    return n->rans;
  else
    return n->ans;
}
int preans(node *n, int tag = 0) {
  if (n->tag ^ tag) return n->rpreans;
  return n->preans;
}
int sufans(node *n, int tag = 0) {
  if (n->tag ^ tag) return n->rsufans;
  return n->sufans;
}
void pull(node *n) {
  if (pre(n->l) == n->l->b - n->l->a + 1) {
    n->pre = pre(n->l) + pre(n->r);
  } else {
    n->pre = pre(n->l);
  }
  if (suf(n->l) == n->l->b - n->l->a + 1) {
    n->preans = suf(n->l) + preans(n->r);
  } else if (preans(n->l) == n->l->b - n->l->a + 1)
    n->preans = preans(n->l) + pre(n->r);
  else
    n->preans = preans(n->l);
  if (suf(n->r) == n->r->b - n->r->a + 1)
    n->suf = suf(n->r) + suf(n->l);
  else
    n->suf = suf(n->r);
  if (pre(n->r) == n->r->b - n->r->a + 1) {
    n->sufans = pre(n->r) + sufans(n->l);
  } else if (sufans(n->r) == n->r->b - n->r->a + 1) {
    n->sufans = sufans(n->r) + suf(n->l);
  } else {
    n->sufans = sufans(n->r);
  }
  n->ans = max(max(ans(n->l), ans(n->r)),
               max(preans(n->r) + suf(n->l), sufans(n->l) + pre(n->r)));
  if (pre(n->l, 1) == n->l->b - n->l->a + 1) {
    n->rpre = pre(n->l, 1) + pre(n->r, 1);
  } else {
    n->rpre = pre(n->l, 1);
  }
  if (suf(n->l, 1) == n->l->b - n->l->a + 1) {
    n->rpreans = suf(n->l, 1) + preans(n->r, 1);
  } else if (preans(n->l, 1) == n->l->b - n->l->a + 1)
    n->rpreans = preans(n->l, 1) + pre(n->r, 1);
  else
    n->rpreans = preans(n->l, 1);
  if (suf(n->r, 1) == n->r->b - n->r->a + 1)
    n->rsuf = suf(n->r, 1) + suf(n->l, 1);
  else
    n->rsuf = suf(n->r, 1);
  if (pre(n->r, 1) == n->r->b - n->r->a + 1) {
    n->rsufans = pre(n->r, 1) + sufans(n->l, 1);
  } else if (sufans(n->r, 1) == n->r->b - n->r->a + 1) {
    n->rsufans = sufans(n->r, 1) + suf(n->l, 1);
  } else {
    n->rsufans = sufans(n->r, 1);
  }
  n->rans =
      max(max(ans(n->l, 1), ans(n->r, 1)),
          max(preans(n->r, 1) + suf(n->l, 1), sufans(n->l, 1) + pre(n->r, 1)));
}
void push(node *n) {
  n->l->tag ^= n->tag;
  n->r->tag ^= n->tag;
  n->tag = 0;
}
void build(node *n, char *c) {
  if (n->a == n->b) {
    if (c[n->a] == '<')
      n->pre = n->preans = n->sufans = n->ans = n->rsuf = n->rsufans =
          n->rpreans = n->rans = 1;
    else
      n->suf = n->sufans = n->preans = n->ans = n->rpre = n->rpreans =
          n->rsufans = n->rans = 1;
    return;
  }
  int mid = (n->a + n->b) / 2;
  n->l = new node(n->a, mid);
  n->r = new node(mid + 1, n->b);
  build(n->l, c);
  build(n->r, c);
  pull(n);
}
node revise(node *n, int l, int r) {
  if (n->a >= l && n->b <= r) {
    n->tag ^= 1;
    return *n;
  }
  if (n->b < l || n->a > r) {
    return node(0, 0);
  }
  push(n);
  node ln = revise(n->l, l, r);
  node rn = revise(n->r, l, r);
  pull(n);
  if (ans(&ln) == 0) return rn;
  if (ans(&rn) == 0) return ln;
  ln.a = max(ln.a, l);
  rn.b = min(rn.b, r);
  node res(max(n->a, l), min(n->b, r));
  res.l = &ln;
  res.r = &rn;
  pull(&res);
  return res;
}
int main() {
  int n, q;
  scanf("%d %d", &n, &q);
  char c[500005];
  scanf("%s", c + 1);
  root = new node(1, n);
  build(root, c);
  while (q--) {
    int l, r;
    scanf("%d %d", &l, &r);
    node res = revise(root, l, r);
    printf("%d\n", ans(&res));
  }
  return 0;
}