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;
inline int read_int() {
  int t = 0;
  bool sign = false;
  char c = getchar();
  while (!isdigit(c)) {
    sign |= c == '-';
    c = getchar();
  }
  while (isdigit(c)) {
    t = (t << 1) + (t << 3) + (c & 15);
    c = getchar();
  }
  return sign ? -t : t;
}
inline long long read_LL() {
  long long t = 0;
  bool sign = false;
  char c = getchar();
  while (!isdigit(c)) {
    sign |= c == '-';
    c = getchar();
  }
  while (isdigit(c)) {
    t = (t << 1) + (t << 3) + (c & 15);
    c = getchar();
  }
  return sign ? -t : t;
}
inline void write(long long x) {
  register char c[21], len = 0;
  if (!x) return putchar('0'), void();
  if (x < 0) x = -x, putchar('-');
  while (x) c[++len] = x % 10, x /= 10;
  while (len) putchar(c[len--] + 48);
}
inline void space(long long x) { write(x), putchar(' '); }
inline void enter(long long x) { write(x), putchar('\n'); }
const int MAXN = 5e5 + 5;
struct Node {
  int str[2][2], ans;
  bool type;
} node[MAXN << 2][2];
int lef[MAXN << 2], rig[MAXN << 2];
bool isleaf[MAXN << 2], lazy[MAXN << 2];
char buf[MAXN];
Node merge(const Node &lef, const Node &rig) {
  Node temp;
  temp.ans = max(lef.ans, rig.ans);
  if (lef.type && rig.type) {
    temp.type = true;
    temp.str[0][0] = lef.str[0][0];
    temp.str[0][1] = lef.str[0][1];
    temp.str[1][0] = rig.str[1][0];
    temp.str[1][1] = rig.str[1][1];
    if (lef.str[1][1] && rig.str[0][0])
      temp.ans =
          max(max(lef.str[1][0] + lef.str[1][1], rig.str[0][0] + rig.str[0][1]),
              temp.ans);
    else
      temp.ans =
          max(lef.str[1][0] + lef.str[1][1] + rig.str[0][0] + rig.str[0][1],
              temp.ans);
  } else if (lef.type) {
    temp.type = true;
    temp.str[0][0] = lef.str[0][0];
    temp.str[0][1] = lef.str[0][1];
    if (lef.str[1][1] && rig.str[0][0]) {
      temp.ans = max(lef.str[1][0] + lef.str[1][1], temp.ans);
      temp.str[1][0] = rig.str[0][0];
      temp.str[1][1] = rig.str[0][1];
    } else {
      temp.str[1][0] = lef.str[1][0] + rig.str[0][0];
      temp.str[1][1] = lef.str[1][1] + rig.str[0][1];
    }
  } else if (rig.type) {
    temp.type = true;
    temp.str[1][0] = rig.str[1][0];
    temp.str[1][1] = rig.str[1][1];
    if (lef.str[0][1] && rig.str[0][0]) {
      temp.ans = max(rig.str[0][0] + rig.str[0][1], temp.ans);
      temp.str[0][0] = lef.str[0][0];
      temp.str[0][1] = lef.str[0][1];
    } else {
      temp.str[0][0] = lef.str[0][0] + rig.str[0][0];
      temp.str[0][1] = lef.str[0][1] + rig.str[0][1];
    }
  } else {
    if (lef.str[0][1] && rig.str[0][0]) {
      temp.type = true;
      temp.str[0][0] = lef.str[0][0];
      temp.str[0][1] = lef.str[0][1];
      temp.str[1][0] = rig.str[0][0];
      temp.str[1][1] = rig.str[0][1];
    } else {
      temp.type = false;
      temp.str[0][0] = lef.str[0][0] + rig.str[0][0];
      temp.str[0][1] = lef.str[0][1] + rig.str[0][1];
      temp.str[1][0] = temp.str[1][1] = 0;
    }
  }
  return temp;
}
void push_down(int k) {
  if (lazy[k]) {
    swap(node[k][0], node[k][1]);
    lazy[k] = false;
    if (!isleaf[k]) lazy[k << 1] ^= 1, lazy[k << 1 | 1] ^= 1;
  }
}
void push_up(int k) {
  push_down(k << 1);
  push_down(k << 1 | 1);
  node[k][0] = merge(node[k << 1][0], node[k << 1 | 1][0]);
  node[k][1] = merge(node[k << 1][1], node[k << 1 | 1][1]);
}
void build(int k, int L, int R) {
  lef[k] = L, rig[k] = R;
  int M = L + R >> 1;
  if (L == R) {
    isleaf[k] = true;
    if (buf[M] == '<') {
      node[k][0].str[0][1] = 1;
      node[k][1].str[0][0] = 1;
    } else {
      node[k][0].str[0][0] = 1;
      node[k][1].str[0][1] = 1;
    }
    return;
  }
  build(k << 1, L, M);
  build(k << 1 | 1, M + 1, R);
  push_up(k);
}
void update(int k, int L, int R) {
  if (L <= lef[k] && rig[k] <= R) return lazy[k] ^= 1, void();
  push_down(k);
  int mid = lef[k] + rig[k] >> 1;
  if (mid < L)
    update(k << 1 | 1, L, R);
  else if (mid >= R)
    update(k << 1, L, R);
  else {
    update(k << 1, L, R);
    update(k << 1 | 1, L, R);
  }
  push_up(k);
}
Node query(int k, int L, int R) {
  push_down(k);
  if (L <= lef[k] && rig[k] <= R) return node[k][0];
  int mid = lef[k] + rig[k] >> 1;
  if (mid < L)
    return query(k << 1 | 1, L, R);
  else if (mid >= R)
    return query(k << 1, L, R);
  else
    return merge(query(k << 1, L, R), query(k << 1 | 1, L, R));
}
int main() {
  int n = read_int(), q = read_int(), l, r;
  Node temp;
  scanf("%s", buf + 1);
  build(1, 1, n);
  while (q--) {
    l = read_int(), r = read_int();
    update(1, l, r);
    temp = query(1, l, r);
    enter(max(temp.ans, max(temp.str[0][0] + temp.str[0][1],
                            temp.str[1][0] + temp.str[1][1])));
  }
  return 0;
}