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 maxn = 5e5 + 7;
enum DIR { LEFT, RIGHT };
DIR s[maxn];
struct point {
  int r, l;
  bool can_plus(const point& o) { return !l || !o.r; }
  point operator+(const point& o) { return (point){r + o.r, l + o.l}; }
  int sum() { return r + l; }
};
struct node {
  point pre, suf;
  int inter;
  node() : pre(), suf(), inter() {}
} tre[maxn << 2][2];
bool tag[maxn << 2];
stack<point> st, ans;
node merge(node left, node right) {
  st.emplace(right.suf);
  st.emplace(right.pre);
  st.emplace(left.suf);
  st.emplace(left.pre);
  while (!st.empty()) {
    point tmp = st.top();
    st.pop();
    if (st.empty() || !tmp.can_plus(st.top())) {
      ans.emplace(tmp);
    } else {
      tmp = tmp + st.top();
      st.pop();
      st.emplace(tmp);
    }
  }
  node now;
  now.inter = max(left.inter, right.inter);
  if (ans.size() == 1) {
    now.pre = ans.top();
    ans.pop();
    return now;
  } else {
    now.suf = ans.top();
    ans.pop();
  }
  while (!ans.empty()) {
    point tmp = ans.top();
    ans.pop();
    if (ans.empty()) {
      now.pre = tmp;
    } else {
      now.inter = max(now.inter, tmp.sum());
    }
  }
  return now;
}
void build(int o, int l, int r, bool t) {
  if (l == r) {
    tre[o][t].pre.l = (s[l] ^ t) == LEFT;
    tre[o][t].pre.r = (s[l] ^ t) == RIGHT;
    return;
  }
  build((o << 1), l, ((l + r) >> 1), t);
  build(((o << 1) | 1), ((l + r) >> 1) + 1, r, t);
  tre[o][t] = merge(tre[(o << 1)][t], tre[((o << 1) | 1)][t]);
}
void pdown(int o, bool t) {
  if (tag[o] && !t) {
    swap(tre[(o << 1)][0], tre[(o << 1)][1]);
    swap(tre[((o << 1) | 1)][0], tre[((o << 1) | 1)][1]);
    tag[(o << 1)] ^= true;
    tag[((o << 1) | 1)] ^= true;
    tag[o] = false;
  }
}
void upd(int o, int l, int r, int ql, int qr, bool t) {
  if (ql <= l && r <= qr) {
    if (!t) {
      swap(tre[o][0], tre[o][1]);
      tag[o] ^= true;
    }
    return;
  }
  pdown(o, t);
  if (ql <= ((l + r) >> 1)) {
    upd((o << 1), l, ((l + r) >> 1), ql, qr, t);
  }
  if (qr > ((l + r) >> 1)) {
    upd(((o << 1) | 1), ((l + r) >> 1) + 1, r, ql, qr, t);
  }
  tre[o][t] = merge(tre[(o << 1)][t], tre[((o << 1) | 1)][t]);
}
node qry(int o, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr) {
    return tre[o][0];
  }
  node ans;
  if (ql <= ((l + r) >> 1)) {
    ans = merge(ans, qry((o << 1), l, ((l + r) >> 1), ql, qr));
  }
  if (qr > ((l + r) >> 1)) {
    ans = merge(ans, qry(((o << 1) | 1), ((l + r) >> 1) + 1, r, ql, qr));
  }
  return ans;
}
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  getchar();
  char c;
  int cnt = 0;
  while ((c = getchar()) != '\n') {
    if (c == '<') {
      s[cnt++] = LEFT;
    } else {
      s[cnt++] = RIGHT;
    }
  }
  build(1, 0, n - 1, 0);
  build(1, 0, n - 1, 1);
  while (q--) {
    int l, r;
    scanf("%d%d", &l, &r);
    upd(1, 0, n - 1, l - 1, r - 1, 0);
    upd(1, 0, n - 1, l - 1, r - 1, 1);
    node ans = qry(1, 0, n - 1, l - 1, r - 1);
    printf("%d\n", max(ans.inter, max(ans.pre.sum(), ans.suf.sum())));
  }
}