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;
const int oo = 1e9 + 5;
const long long int ooll = 1e18 + 5;
const int MOD = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct SegNode {
  int cont[2][4], len, ans, ansinv;
  SegNode() : len(0), ans(0), ansinv(0) { memset(cont, 0, sizeof(cont)); }
  SegNode(char c) {
    for (int i = 0; i < 2; ++i)
      for (int j = 0; j < 4; ++j) cont[i][j] = 1;
    if (c == '>') {
      cont[0][0] = cont[1][0] = 0;
    } else {
      cont[0][3] = cont[1][3] = 0;
    }
    len = ans = ansinv = 1;
  }
  void Invert() {
    swap(cont[0][0], cont[0][3]);
    swap(cont[0][1], cont[0][2]);
    swap(cont[1][0], cont[1][3]);
    swap(cont[1][1], cont[1][2]);
    swap(ans, ansinv);
  }
};
SegNode Merge(SegNode L, SegNode R) {
  SegNode res;
  res.len = L.len + R.len;
  res.cont[0][0] = L.cont[0][0] + (L.cont[0][0] == L.len ? R.cont[0][0] : 0);
  res.cont[0][3] = L.cont[0][3] + (L.cont[0][3] == L.len ? R.cont[0][3] : 0);
  res.cont[0][1] = L.cont[0][1] + (L.cont[0][1] == L.len ? R.cont[0][3] : 0);
  if (L.cont[0][0] == L.len)
    res.cont[0][1] = max(res.cont[0][1], L.cont[0][0] + R.cont[0][1]);
  res.cont[0][2] = L.cont[0][2] + (L.cont[0][2] == L.len ? R.cont[0][0] : 0);
  if (L.cont[0][3] == L.len)
    res.cont[0][2] = max(res.cont[0][2], L.cont[0][3] + R.cont[0][2]);
  res.cont[1][0] = R.cont[1][0] + (R.cont[1][0] == R.len ? L.cont[1][0] : 0);
  res.cont[1][3] = R.cont[1][3] + (R.cont[1][3] == R.len ? L.cont[1][3] : 0);
  res.cont[1][1] = R.cont[1][1] + (R.cont[1][1] == R.len ? L.cont[1][0] : 0);
  if (R.cont[1][3] == R.len)
    res.cont[1][1] = max(res.cont[1][1], R.cont[1][3] + L.cont[1][1]);
  res.cont[1][2] = R.cont[1][2] + (R.cont[1][2] == R.len ? L.cont[1][3] : 0);
  if (R.cont[1][0] == R.len)
    res.cont[1][2] = max(res.cont[1][2], R.cont[1][0] + L.cont[1][2]);
  res.ans = max(
      {L.ans, R.ans, L.cont[1][3] + R.cont[0][2], L.cont[1][2] + R.cont[0][0]});
  res.ansinv = max({L.ansinv, R.ansinv, L.cont[1][0] + R.cont[0][1],
                    L.cont[1][1] + R.cont[0][3]});
  return res;
}
SegNode tree[4 * N];
int lz[4 * N];
string s;
void build(int node, int st, int en) {
  lz[node] = 0;
  if (st == en) {
    tree[node] = SegNode(s[st]);
    return;
  }
  int m = (st + en) >> 1;
  build(2 * node + 1, st, m);
  build(2 * node + 2, m + 1, en);
  tree[node] = Merge(tree[2 * node + 1], tree[2 * node + 2]);
}
void upd(int l, int r, int node, int st, int en) {
  if (lz[node]) {
    if (st < en) {
      lz[2 * node + 1] ^= 1;
      lz[2 * node + 2] ^= 1;
    }
    tree[node].Invert();
    lz[node] = 0;
  }
  if (st > r || en < l) return;
  if (st >= l && en <= r) {
    tree[node].Invert();
    if (st < en) {
      lz[2 * node + 1] ^= 1;
      lz[2 * node + 2] ^= 1;
    }
    return;
  }
  int m = (st + en) >> 1;
  upd(l, r, 2 * node + 1, st, m);
  upd(l, r, 2 * node + 2, m + 1, en);
  tree[node] = Merge(tree[2 * node + 1], tree[2 * node + 2]);
}
SegNode query(int l, int r, int node, int st, int en) {
  if (lz[node]) {
    if (st < en) {
      lz[2 * node + 1] ^= 1;
      lz[2 * node + 2] ^= 1;
    }
    tree[node].Invert();
    lz[node] = 0;
  }
  if (en < l || st > r) return SegNode();
  if (st >= l && en <= r) return tree[node];
  int m = (st + en) >> 1;
  return Merge(query(l, r, 2 * node + 1, st, m),
               query(l, r, 2 * node + 2, m + 1, en));
}
void prin(SegNode snode) {
  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < 4; ++j) cout << snode.cont[i][j] << " ";
  cout << snode.ans << " ans " << snode.ansinv << " ansinv\n";
}
void disp(int node, int st, int en) {
  cout << node << " ";
  cout << "(" << st << "," << en << ") : ";
  cout << lz[node] << " lz ";
  prin(tree[node]);
  if (st == en) return;
  int m = (st + en) >> 1;
  disp(2 * node + 1, st, m);
  disp(2 * node + 2, m + 1, en);
}
void bruteupd(int l, int r) {
  for (int i = l; i <= r; ++i) s[i] = '>' + '<' - s[i];
}
int brutequery(int l, int r) {
  int ans = 0;
  for (int i = l; i <= r;) {
    int cnt = 0;
    while (i <= r && s[i] == '>') {
      ++cnt;
      ++i;
    }
    while (i <= r && s[i] == '<') {
      ++cnt;
      ++i;
    }
    ans = max(ans, cnt);
  }
  return ans;
}
void solve() {
  int n, q;
  cin >> n >> q;
  cin >> s;
  build(0, 0, n - 1);
  while (q--) {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    upd(l, r, 0, 0, n - 1);
    int go = query(l, r, 0, 0, n - 1).ans;
    cout << go << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int T = 1;
  while (T--) {
    solve();
  }
  return 0;
}