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;
struct Node {
  int sz;
  int ans[2];
  int lpref[2];
  int lsuff[2];
  int apref[2];
  int asuff[2];
  Node() {
    sz = 0;
    fill(ans, ans + 2, 0);
    fill(lpref, lpref + 2, 0);
    fill(lsuff, lsuff + 2, 0);
    fill(apref, apref + 2, 0);
    fill(asuff, asuff + 2, 0);
  }
  Node(int x) {
    sz = 1;
    fill(ans, ans + 2, 0);
    fill(lpref, lpref + 2, 0);
    fill(lsuff, lsuff + 2, 0);
    ans[x] = 1;
    lpref[x] = 1;
    lsuff[x] = 1;
    fill(apref, apref + 2, 1);
    fill(asuff, asuff + 2, 1);
  }
  Node(int sz_, int *ans_, int *lpref_, int *lsuff_, int *apref_, int *asuff_) {
    sz = sz_;
    for (int i = 0; i < 2; i++) {
      ans[i] = ans_[i];
      lpref[i] = lpref_[i];
      lsuff[i] = lsuff_[i];
      apref[i] = apref_[i];
      asuff[i] = asuff_[i];
    }
  }
  friend Node conq(const Node &l, const Node &r) {
    int new_sz;
    new_sz = l.sz + r.sz;
    int new_ans[2];
    new_ans[0] = max({l.ans[0], r.ans[0], l.lsuff[0] + r.lpref[1],
                      l.asuff[0] + r.lpref[1], l.lsuff[0] + r.apref[0]});
    new_ans[1] = max({l.ans[1], r.ans[1], l.lsuff[1] + r.lpref[0],
                      l.asuff[1] + r.lpref[0], l.lsuff[1] + r.apref[1]});
    int new_lpref[2];
    for (int c = 0; c < 2; c++) {
      new_lpref[c] = l.lpref[c];
      if (l.lpref[c] == l.sz) new_lpref[c] += r.lpref[c];
    }
    int new_lsuff[2];
    for (int c = 0; c < 2; c++) {
      new_lsuff[c] = r.lsuff[c];
      if (r.lsuff[c] == r.sz) new_lsuff[c] += l.lsuff[c];
    }
    int new_apref[2];
    for (int f = 0; f < 2; f++) {
      new_apref[f] = l.apref[f];
      if (l.apref[f] == l.sz) {
        if (l.lpref[f] == l.sz) {
          new_apref[f] += r.apref[f];
        } else {
          new_apref[f] += r.lpref[f ^ 1];
        }
      }
    }
    int new_asuff[2];
    for (int f = 0; f < 2; f++) {
      new_asuff[f] = r.asuff[f];
      if (r.asuff[f] == r.sz) {
        if (r.lsuff[f ^ 1] == r.sz) {
          new_asuff[f] += l.asuff[f];
        } else {
          new_asuff[f] += l.lsuff[f];
        }
      }
    }
    return Node(new_sz, new_ans, new_lpref, new_lsuff, new_apref, new_asuff);
  }
  Node inv() const {
    int new_ans[2];
    for (int i = 0; i < 2; i++) {
      new_ans[i] = ans[i ^ 1];
    }
    int new_lpref[2];
    for (int i = 0; i < 2; i++) {
      new_lpref[i] = lpref[i ^ 1];
    }
    int new_lsuff[2];
    for (int i = 0; i < 2; i++) {
      new_lsuff[i] = lsuff[i ^ 1];
    }
    int new_apref[2];
    for (int i = 0; i < 2; i++) {
      new_apref[i] = apref[i ^ 1];
    }
    int new_asuff[2];
    for (int i = 0; i < 2; i++) {
      new_asuff[i] = asuff[i ^ 1];
    }
    return Node(sz, new_ans, new_lpref, new_lsuff, new_apref, new_asuff);
  }
  int solve() { return ans[0]; }
};
const int N = 5e5 + 7;
namespace Segtree {
int n;
Node t[4 * N];
int mod[4 * N];
void pull(int v) { t[v] = conq(t[2 * v + 1], t[2 * v + 2]); }
void apply(int v) {
  t[v] = t[v].inv();
  mod[v] ^= 1;
}
void push(int v) {
  if (mod[v]) {
    apply(2 * v + 1);
    apply(2 * v + 2);
    mod[v] = 0;
  }
}
void build(int v, int l, int r, vector<int> &a) {
  if (l + 1 == r) {
    t[v] = Node(a[l]);
  } else {
    int m = (r + l) >> 1;
    build(2 * v + 1, l, m, a);
    build(2 * v + 2, m, r, a);
    pull(v);
  }
}
void inv(int v, int l, int r, int ql, int qr) {
  if (qr <= l || r <= ql) {
    return;
  } else if (ql <= l && r <= qr) {
    apply(v);
  } else {
    push(v);
    int m = (r + l) >> 1;
    inv(2 * v + 1, l, m, ql, qr);
    inv(2 * v + 2, m, r, ql, qr);
    pull(v);
  }
}
void query(int v, int l, int r, int ql, int qr, Node &ans) {
  if (qr <= l || r <= ql) {
    return;
  } else if (ql <= l && r <= qr) {
    ans = conq(ans, t[v]);
  } else {
    push(v);
    int m = (r + l) >> 1;
    query(2 * v + 1, l, m, ql, qr, ans);
    query(2 * v + 2, m, r, ql, qr, ans);
    pull(v);
  }
}
int solve(int l, int r) {
  Node ans = Node();
  query(0, 0, n, l, r, ans);
  return ans.solve();
}
void inv(int l, int r) { inv(0, 0, n, l, r); }
void init(vector<int> &a) {
  n = (int)a.size();
  build(0, 0, n, a);
}
}  // namespace Segtree
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  vector<int> a;
  for (int i = 0; i < n; i++) {
    char c;
    cin >> c;
    if (c == '>')
      a.push_back(0);
    else
      a.push_back(1);
  }
  Segtree::init(a);
  while (q--) {
    int l, r;
    cin >> l >> r;
    l--;
    Segtree::inv(l, r);
    cout << Segtree::solve(l, r) << '\n';
  }
}