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;
const int N = 500010;
char arr[N];
int n, q;
inline char Not(char x) {
  if (x == '>') return '<';
  return '>';
}
struct S {
  char a, b;
  int s1, s2, l1, l2;
  int mx[2];
  int all;
  void zero() { s1 = s2 = l1 = l2 = mx[0] = mx[1] = all = 0; }
  void make(char x) {
    mx[0] = mx[1] = 1;
    a = b = x;
    s1 = l1 = 1;
    s2 = l2 = 0;
    all = 1;
  }
  void make2(const S &l, const S &r) {
    if (l.s1 + l.s2 == 0) {
      (*this) = r;
      return;
    }
    if (r.s1 + r.s2 == 0) {
      (*this) = l;
      return;
    }
    mx[0] = max(l.mx[0], r.mx[0]);
    mx[1] = max(l.mx[1], r.mx[1]);
    if (l.b == '>') {
      if (r.a == '>')
        mx[0] = max(mx[0], l.l1 + r.s1 + r.s2),
        mx[1] = max(mx[1], l.l1 + l.l2 + r.s1);
      else
        mx[0] = max(mx[0], l.l1 + r.s1);
    } else {
      if (r.a == '>')
        mx[1] = max(mx[1], l.l1 + r.s1);
      else
        mx[0] = max(mx[0], l.l1 + l.l2 + r.s1),
        mx[1] = max(mx[1], l.l1 + r.s1 + r.s2);
    }
    all = l.all + r.all - (l.b == r.a ? 1 : 0);
    s1 = l.s1;
    if (l.s2 == 0) {
      if (l.b == r.a) {
        s1 += r.s1;
        s2 = r.s2;
      } else {
        s2 = r.s1;
      }
    } else {
      s2 = l.s2;
      if (l.all < 3 && l.b == r.a) s2 += r.s1;
    }
    l1 = r.l1;
    if (r.l2 == 0) {
      if (l.b == r.a) {
        l1 += l.l1;
        l2 = l.l2;
      } else
        l2 = l.l1;
    } else {
      l2 = r.l2;
      if (r.all < 3 && l.b == r.a) l2 += l.l1;
    }
    a = l.a;
    b = r.b;
  }
  void operator=(const S &other) {
    a = other.a, b = other.b;
    mx[0] = other.mx[0], mx[1] = other.mx[1];
    all = other.all, s1 = other.s1, s2 = other.s2, l1 = other.l1, l2 = other.l2;
  }
  void Print() {
    printf("mx[0] = %d , mx[1] = %d\n", mx[0], mx[1]);
    printf("start with %c, ends with %c\n", a, b);
    printf("(%d,%d)(%d,%d)\n", s1, s2, l1, l2);
    printf("all = %d\n", all);
  }
};
S seg[4 * N];
int lazy[4 * N];
inline void fix(int s, int e, int idx) {
  if (lazy[idx] == 1) {
    swap(seg[idx].mx[0], seg[idx].mx[1]);
    seg[idx].a = Not(seg[idx].a);
    seg[idx].b = Not(seg[idx].b);
  }
  if (s != e) {
    lazy[(idx << 1)] ^= lazy[idx];
    lazy[(idx << 1) + 1] ^= lazy[idx];
  }
  lazy[idx] = 0;
}
void build(int s, int e, int idx) {
  if (s == e) {
    seg[idx].make(arr[e]);
    return;
  }
  build(s, ((s + e) >> 1), (idx << 1));
  build(((s + e) >> 1) + 1, e, (idx << 1) + 1);
  seg[idx].make2(seg[(idx << 1)], seg[(idx << 1) + 1]);
}
int l, r;
void update(int s, int e, int idx) {
  fix(s, e, idx);
  if (s > r || e < l) return;
  if (s >= l && e <= r) {
    lazy[idx] ^= 1;
    fix(s, e, idx);
    return;
  }
  update(s, ((s + e) >> 1), (idx << 1));
  update(((s + e) >> 1) + 1, e, (idx << 1) + 1);
  seg[idx].make2(seg[(idx << 1)], seg[(idx << 1) + 1]);
}
S gt[4 * N];
void get(int s, int e, int idx) {
  if (s > r || e < l) {
    gt[idx].zero();
    return;
  }
  if (s >= l && e <= r) {
    gt[idx] = seg[idx];
    return;
  }
  get(s, ((s + e) >> 1), (idx << 1));
  get(((s + e) >> 1) + 1, e, (idx << 1) + 1);
  gt[idx].make2(gt[(idx << 1)], gt[(idx << 1) + 1]);
}
int main() {
  scanf("%d%d", &n, &q);
  scanf("%s", arr);
  build(0, n - 1, 1);
  while (q--) {
    scanf("%d%d", &l, &r);
    l--, r--;
    update(0, n - 1, 1);
    get(0, n - 1, 1);
    printf("%d\n", gt[1].mx[0]);
  }
  return 0;
}