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 = (int)5e5 + 10;
int n, q;
char s[maxN];
struct node {
  int to_left;
  int to_right;
  int tp_left;
  int tp_right;
  int max_ans;
  int sz;
  int f01, f10;
  int lele;
  int riri;
  node() {
    to_left = 0;
    to_right = 0;
    max_ans = 0;
    sz = 0;
    tp_left = 0;
    tp_right = 0;
    f01 = 0;
    f10 = 0;
    lele = 0;
    riri = 0;
  }
};
const int LEFT = 0;
const int RIGHT = 1;
node t[4 * maxN];
bool flip[4 * maxN];
node merge(const node &a, const node &b) {
  node c;
  c.sz = a.sz + b.sz;
  c.max_ans = max(a.max_ans, b.max_ans);
  c.tp_left = a.tp_left;
  c.to_left = a.to_left;
  if (a.to_left == a.sz) {
    if (a.tp_right == b.tp_left) {
      c.to_left += b.to_left;
      c.lele = b.lele;
    } else {
      c.lele = b.to_left;
    }
  } else {
    c.lele = a.lele;
    if (a.to_left + a.lele == a.sz && a.tp_right == b.tp_left) {
      c.lele += b.to_left;
    }
  }
  c.tp_right = b.tp_right;
  c.to_right = b.to_right;
  if (b.to_right == b.sz) {
    if (b.tp_right == a.tp_right) {
      c.to_right += a.to_right;
      c.riri = a.riri;
    } else {
      c.riri = a.to_right;
    }
  } else {
    c.riri = b.riri;
    if (b.to_right + b.riri == b.sz && b.tp_left == a.tp_right) {
      c.riri += a.to_right;
    }
  }
  c.max_ans = max(c.max_ans, max(c.to_left, c.to_right));
  c.f01 = max(a.f01, b.f01);
  c.f10 = max(a.f10, b.f10);
  if (a.tp_right == b.tp_left) {
    if (a.tp_right == LEFT) {
      c.f01 = max(c.f01, a.riri + a.to_right + b.to_left);
      c.f10 = max(c.f10, b.lele + a.to_right + b.to_left);
    } else {
      c.f01 = max(c.f01, b.lele + a.to_right + b.to_left);
      c.f10 = max(c.f10, a.riri + a.to_right + b.to_left);
    }
  } else {
    if (a.tp_right == RIGHT) {
      c.f01 = max(c.f01, a.to_right + b.to_left);
    } else {
      c.f10 = max(c.f10, a.to_right + b.to_left);
    }
  }
  return c;
}
void apply(int v) {
  flip[v] ^= 1;
  t[v].tp_right ^= 1;
  t[v].tp_left ^= 1;
  swap(t[v].f01, t[v].f10);
}
void push(int v, int tl, int tr) {
  if (tl != tr && flip[v]) {
    apply(2 * v);
    apply(2 * v + 1);
  }
  flip[v] = false;
}
void merge(int v) { t[v] = merge(t[2 * v], t[2 * v + 1]); }
void build(int v, int tl, int tr) {
  if (tl == tr) {
    t[v].to_left = t[v].to_right = t[v].sz = t[v].max_ans = 1;
    if (s[tl] == '<') {
      t[v].tp_right = t[v].tp_left = LEFT;
    } else {
      t[v].tp_right = t[v].tp_left = RIGHT;
    }
    return;
  }
  int tm = (tl + tr) / 2;
  build(2 * v, tl, tm);
  build(2 * v + 1, tm + 1, tr);
  merge(v);
}
void upd(int v, int tl, int tr, int l, int r) {
  if (r < tl || l > tr) return;
  if (l <= tl && tr <= r) {
    apply(v);
    return;
  }
  push(v, tl, tr);
  int tm = (tl + tr) / 2;
  upd(2 * v, tl, tm, l, r);
  upd(2 * v + 1, tm + 1, tr, l, r);
  merge(v);
}
node get(int v, int tl, int tr, int l, int r) {
  if (tl == l && tr == r) {
    return t[v];
  }
  push(v, tl, tr);
  int tm = (tl + tr) / 2;
  if (r <= tm)
    return get(2 * v, tl, tm, l, r);
  else if (l > tm)
    return get(2 * v + 1, tm + 1, tr, l, r);
  else
    return merge(get(2 * v, tl, tm, l, tm),
                 get(2 * v + 1, tm + 1, tr, tm + 1, r));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> q;
  s[0] = '>';
  s[n + 1] = '<';
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
  }
  build(1, 0, n + 1);
  while (q--) {
    int l, r;
    cin >> l >> r;
    upd(1, 0, n + 1, l, r);
    auto nt = get(1, 0, n + 1, l, r);
    cout << max(nt.max_ans, nt.f01) << '\n';
  }
  return 0;
}