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 long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  return x * f;
}
inline void write(long long x) {
  if (x < 0) x = -x, putchar('-');
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
inline void writeln(long long x) {
  write(x);
  putchar('\n');
}
inline void wri(long long x) {
  write(x);
  putchar(' ');
}
const int maxn = 5e5 + 233;
char s[maxn];
int n, q, b[maxn];
struct node {
  int s, l0, r1, al, ar, len;
  node() { s = l0 = al = ar = r1 = len = 0; }
} T[maxn << 2], rT[maxn << 2];
int tag[maxn << 2];
void pushup(node &ans, node a, node b) {
  ans.s = max(a.s, b.s),
  ans.s = (ans.s) < (a.r1 + b.l0) ? (a.r1 + b.l0) : (ans.s);
  ans.s = (ans.s) < (a.ar + b.l0) ? (a.ar + b.l0) : (ans.s);
  ans.s = (ans.s) < (a.r1 + b.al) ? (a.r1 + b.al) : (ans.s);
  ans.s = (ans.s) < (max(a.al, b.ar)) ? (max(a.al, b.ar)) : (ans.s);
  ans.l0 = (a.len == a.l0) ? a.len + b.l0 : a.l0;
  ans.r1 = (b.len == b.r1) ? b.len + a.r1 : b.r1;
  ans.al = (a.len == a.r1) ? a.r1 + max(b.al, b.l0)
           : a.len == a.al ? a.len + b.l0
                           : a.al;
  ans.ar = (b.len == b.l0) ? b.l0 + max(a.ar, a.r1)
           : b.len == b.ar ? b.len + a.r1
                           : b.ar;
  ans.len = a.len + b.len;
}
void build(int o, int l, int r) {
  if (l == r) {
    T[o].len = r - l + 1;
    rT[o].len = r - l + 1;
    T[o].s = rT[o].s = 1;
    if (s[l] == '>')
      T[o].al = T[o].r1 = 1, rT[o].ar = rT[o].l0 = 1;
    else
      T[o].ar = T[o].l0 = 1, rT[o].al = rT[o].r1 = 1;
    return;
  }
  build((o << 1), l, ((l + r) >> 1));
  build((o << 1 | 1), ((l + r) >> 1) + 1, r);
  pushup(T[o], T[(o << 1)], T[(o << 1 | 1)]);
  pushup(rT[o], rT[(o << 1)], rT[(o << 1 | 1)]);
}
void pushdown(int o) {
  if (tag[o]) {
    swap(T[(o << 1)], rT[(o << 1)]), tag[(o << 1)] ^= 1;
    swap(T[(o << 1 | 1)], rT[(o << 1 | 1)]), tag[(o << 1 | 1)] ^= 1;
    tag[o] ^= 1;
  }
}
void modify(int o, int l, int r, int x, int y) {
  if (l == x && r == y) {
    swap(T[o], rT[o]);
    tag[o] ^= 1;
    return;
  }
  pushdown(o);
  if (y <= ((l + r) >> 1))
    modify((o << 1), l, ((l + r) >> 1), x, y);
  else if (((l + r) >> 1) + 1 <= x)
    modify((o << 1 | 1), ((l + r) >> 1) + 1, r, x, y);
  else
    modify((o << 1), l, ((l + r) >> 1), x, ((l + r) >> 1)),
        modify((o << 1 | 1), ((l + r) >> 1) + 1, r, ((l + r) >> 1) + 1, y);
  pushup(T[o], T[(o << 1)], T[(o << 1 | 1)]);
  pushup(rT[o], rT[(o << 1)], rT[(o << 1 | 1)]);
}
node query(int o, int l, int r, int x, int y) {
  if (l == x && r == y) return T[o];
  pushdown(o);
  if (y <= ((l + r) >> 1))
    return query((o << 1), l, ((l + r) >> 1), x, y);
  else if (((l + r) >> 1) + 1 <= x)
    return query((o << 1 | 1), ((l + r) >> 1) + 1, r, x, y);
  else {
    node ans;
    node A = query((o << 1), l, ((l + r) >> 1), x, ((l + r) >> 1));
    node B = query((o << 1 | 1), ((l + r) >> 1) + 1, r, ((l + r) >> 1) + 1, y);
    pushup(ans, A, B);
    return ans;
  }
}
int main() {
  n = read(), q = read();
  scanf("%s", s + 1);
  build(1, 1, n);
  for (int i = (1); i <= int(q); ++i) {
    int l = read(), r = read();
    modify(1, 1, n, l, r);
    node ans = query(1, 1, n, l, r);
    writeln(max(ans.s, max(ans.l0, ans.r1)));
  }
  return 0;
}