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 = 5e5 + 5;
struct node {
  int pref[2][2];
  int suf[2][2];
  int ans[2];
  int size;
  node() {
    for (int i : {0, 1}) {
      for (int j : {0, 1}) {
        pref[i][j] = suf[i][j] = 0;
      }
    }
    ans[0] = ans[1] = 1;
    size = 0;
  }
};
node t[N << 2];
bool d[N << 2];
void upd(int v) {
  swap(t[v].pref[0], t[v].pref[1]);
  swap(t[v].suf[0], t[v].suf[1]);
  swap(t[v].ans[0], t[v].ans[1]);
  d[v] ^= 1;
}
void push(int v) {
  if (d[v]) {
    upd(v + v + 1);
    upd(v + v + 2);
    d[v] = 0;
  }
}
node unite(node lc, node rc) {
  if (lc.size == 0) {
    return rc;
  }
  if (rc.size == 0) {
    return lc;
  }
  node res;
  res.size = lc.size + rc.size;
  for (int c : {0, 1}) {
    auto lp = lc.pref[c], ls = lc.suf[c];
    auto rp = rc.pref[c], rs = rc.suf[c];
    auto &ep = res.pref[c], &es = res.suf[c];
    ep[0] = lp[0];
    if (ep[0] == lc.size) {
      ep[0] += rp[0];
    }
    ep[1] = lp[1];
    if (ep[1] == lc.size) {
      ep[1] += rp[0];
    }
    if (ls[0] == lc.size && rp[1] != 0) {
      ep[1] = max(ep[1], lc.size + rp[1]);
    }
    if (ls[0] == lc.size && rp[0] != 0) {
      ep[1] = max(ep[1], lc.size + rp[0]);
    }
    es[0] = rs[0];
    if (es[0] == rc.size) {
      es[0] += ls[0];
    }
    es[1] = rs[1];
    if (es[1] == rc.size) {
      es[1] += ls[0];
    }
    if (rp[0] == rc.size && ls[1] != 0) {
      es[1] = max(es[1], rc.size + ls[1]);
    }
    if (rp[0] == rc.size && ls[0] != 0) {
      es[1] = max(es[1], rc.size + ls[0]);
    }
    res.ans[c] = max(lc.ans[c], rc.ans[c]);
    res.ans[c] = max(res.ans[c], ls[0] + rp[0]);
    res.ans[c] = max(res.ans[c], ls[0] + rp[1]);
    res.ans[c] = max(res.ans[c], ls[1] + rp[0]);
    if (lp[0] == lc.size) {
      res.ans[c] = max(res.ans[c], lc.size + rp[0]);
    }
    if (rs[0] == rc.size) {
      res.ans[c] = max(res.ans[c], rc.size + ls[0]);
    }
  }
  return res;
}
inline void pull(int v) { t[v] = unite(t[v + v + 1], t[v + v + 2]); }
int n;
string s;
void build(int v = 0, int tl = 0, int tr = n) {
  if (tr - tl == 1) {
    t[v].size = tr - tl;
    t[v].pref[0][0] = s[tl] == '<';
    t[v].pref[1][0] = s[tl] == '>';
    t[v].suf[0][0] = s[tl] == '>';
    t[v].suf[1][0] = s[tl] == '<';
    return;
  }
  int tm = (tl + tr) / 2;
  build(v + v + 1, tl, tm);
  build(v + v + 2, tm, tr);
  pull(v);
}
void upd(int l, int r, int v = 0, int tl = 0, int tr = n) {
  if (r <= tl || tr <= l) {
    return;
  }
  if (l <= tl && tr <= r) {
    return upd(v);
  }
  push(v);
  int tm = (tl + tr) / 2;
  upd(l, r, v + v + 1, tl, tm);
  upd(l, r, v + v + 2, tm, tr);
  pull(v);
}
node get(int l, int r, int v = 0, int tl = 0, int tr = n) {
  if (r <= tl || tr <= l) {
    return node();
  }
  if (l <= tl && tr <= r) {
    return t[v];
  }
  push(v);
  int tm = (tl + tr) / 2;
  return unite(get(l, r, v + v + 1, tl, tm), get(l, r, v + v + 2, tm, tr));
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int q;
  cin >> n >> q >> s;
  build();
  while (q--) {
    int l, r;
    cin >> l >> r;
    --l;
    upd(l, r);
    cout << get(l, r).ans[0] << '\n';
  }
  return 0;
}