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 = 2e6 + 12;
bool debag = false;
struct vertex {
  int maxcnt, leftcnt, rightcnt, sz, leftsz, rightsz;
  char typeleft, typeright;
  vertex(char type = '<') {
    maxcnt = leftcnt = rightcnt = sz = leftsz = rightsz = 1;
    typeleft = typeright = type;
  }
};
vertex m[2][N];
vertex merg(const vertex& l, const vertex& r) {
  vertex u;
  u.maxcnt = max(l.maxcnt, r.maxcnt);
  if (l.typeleft == r.typeleft && l.leftsz == l.sz) {
    u.leftsz = l.sz + r.leftsz;
  } else
    u.leftsz = l.leftsz;
  if (r.typeright == l.typeright && r.rightsz == r.sz) {
    u.rightsz = r.sz + l.rightsz;
  } else
    u.rightsz = r.rightsz;
  u.typeleft = l.typeleft;
  u.typeright = r.typeright;
  u.sz = l.sz + r.sz;
  if (debag)
    cout << u.maxcnt << ' ' << l.typeright << ' ' << r.typeright << endl;
  if (l.typeright == '>' && r.typeleft == '<') {
    u.maxcnt = max(u.maxcnt, l.rightsz + r.leftsz);
    if (debag) exit(1);
    if (l.sz == l.leftsz)
      u.leftcnt = l.sz + r.leftsz;
    else
      u.leftcnt = l.leftcnt;
    if (r.sz == r.rightsz)
      u.rightcnt = r.sz + l.rightsz;
    else
      u.rightcnt = r.rightcnt;
  }
  if (l.typeright == '<' && r.typeleft == '<') {
    u.maxcnt = max(u.maxcnt, l.rightcnt + r.leftsz);
    if (l.sz == l.leftcnt)
      u.leftcnt = l.sz + r.leftsz;
    else
      u.leftcnt = l.leftcnt;
    if (r.sz == r.leftsz)
      u.rightcnt = l.rightcnt + r.sz;
    else
      u.rightcnt = r.rightcnt;
  }
  if (l.typeright == '>' && r.typeleft == '>') {
    u.maxcnt = max(u.maxcnt, l.rightsz + r.leftcnt);
    if (r.sz == r.rightcnt)
      u.rightcnt = r.sz + l.rightsz;
    else
      u.rightcnt = r.rightcnt;
    if (l.sz == l.rightsz)
      u.leftcnt = l.sz + r.leftcnt;
    else
      u.leftcnt = l.leftcnt;
  }
  if (l.typeright == '<' && r.typeleft == '>') {
    u.rightcnt = r.rightcnt;
    u.leftcnt = l.leftcnt;
  }
  u.maxcnt = max(u.maxcnt, max(u.leftcnt, u.rightcnt));
  return u;
}
bool ninv[N];
void push(int v) {
  if (ninv[v]) {
    ninv[2 * v + 1] ^= 1;
    ninv[2 * v + 2] ^= 1;
    swap(m[0][2 * v + 1], m[1][2 * v + 1]);
    swap(m[0][2 * v + 2], m[1][2 * v + 2]);
  }
  ninv[v] = 0;
}
void recalc(int v) {
  for (int i = 0; i < 2; ++i) m[i][v] = merg(m[i][2 * v + 1], m[i][2 * v + 2]);
}
vertex get(int v, int vl, int vr, int l, int r) {
  if (l <= vl && vr <= r) {
    return m[0][v];
  } else {
    push(v);
    if (l >= (vl + vr) / 2) return get(2 * v + 2, (vl + vr) / 2, vr, l, r);
    if (r <= (vl + vr) / 2) return get(2 * v + 1, vl, (vl + vr) / 2, l, r);
    return merg(get(2 * v + 1, vl, (vl + vr) / 2, l, r),
                get(2 * v + 2, (vl + vr) / 2, vr, l, r));
  }
}
void invert(int v, int vl, int vr, int l, int r) {
  if (l <= vl && vr <= r) {
    ninv[v] ^= 1;
    swap(m[0][v], m[1][v]);
  } else if (l >= vr || vl >= r)
    return;
  else {
    push(v);
    invert(2 * v + 1, vl, (vl + vr) / 2, l, r);
    invert(2 * v + 2, (vl + vr) / 2, vr, l, r);
    recalc(v);
  }
}
void build(int v, int vl, int vr, string& s) {
  if (vl > s.size()) return;
  if (vr - vl > 1) {
    build(2 * v + 1, vl, (vl + vr) / 2, s);
    build(2 * v + 2, (vl + vr) / 2, vr, s);
    recalc(v);
  } else {
    m[0][v] = vertex(s[vl - 1]);
    m[1][v] = vertex(s[vl - 1] == '<' ? '>' : '<');
  }
}
void run() {
  int n, x, i, j, xmin = 1e9 + 1, q, l, r;
  string s;
  cin >> n >> q;
  cin >> s;
  int v = 1;
  while (v < n) v *= 2;
  build(0, 1, v + 1, s);
  while (q--) {
    cin >> l >> r;
    invert(0, 1, v + 1, l, r + 1);
    cout << get(0, 1, v + 1, l, r + 1).maxcnt << "\n";
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int test;
  run();
}