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;
using big = long long;
const int N = 1200000;
int n, m;
char a[N];
struct Data {
  int lmax[2] = {0, 0}, rmax[2] = {0, 0};
  int mx[2] = {0, 0};
  int lmx[2] = {0, 0}, rmx[2] = {0, 0};
  int size;
  bool flip = false;
};
struct Node {
  int l, r;
  Node *c[2];
  Data d;
} mem[N * 2], *cur = mem;
void updatemx(Data &x) {
  if (x.lmax[1] + x.rmax[0] == x.size && x.lmax[1] && x.rmax[0]) {
    x.mx[0] = x.lmx[0] = x.rmx[0] = x.size;
  }
  if (x.lmax[0] + x.rmax[1] == x.size && x.lmax[0] && x.rmax[1]) {
    x.mx[1] = x.lmx[1] = x.rmx[1] = x.size;
  }
  for (int i = 0; i < 2; ++i) {
    x.mx[i] = max(x.mx[i], x.lmx[i]);
    x.mx[i] = max(x.mx[i], x.rmx[i]);
    x.mx[i] = max(x.mx[i], x.lmx[i]);
    x.mx[i] = max(x.mx[i], x.rmx[i]);
  }
}
void update(Data &x, const Data &l, const Data &r) {
  for (int i = 0; i < 2; ++i) {
    x.lmax[i] = l.lmax[i];
    if (l.lmax[i] == l.size) {
      x.lmax[i] = l.size + r.lmax[i];
    }
    x.rmax[i] = r.rmax[i];
    if (r.rmax[i] == r.size) {
      x.rmax[i] = r.size + l.rmax[i];
    }
  }
  for (int i = 0; i < 2; ++i) {
    x.lmx[i] = l.lmx[i];
    if (l.lmx[i] == l.size) {
      x.lmx[i] = l.size + r.lmax[i];
    }
    if (l.lmax[!i] == l.size) {
      x.lmx[i] = max(x.lmx[i], l.size + max(r.lmx[i], r.lmax[i]));
    }
    x.rmx[i] = r.rmx[i];
    if (r.rmx[i] == r.size) {
      x.rmx[i] = r.size + l.rmax[!i];
    }
    if (r.rmax[i] == r.size) {
      x.rmx[i] = max(x.rmx[i], r.size + max(l.rmx[i], l.rmax[!i]));
    }
    x.mx[i] = 0;
    x.mx[i] = max(x.mx[i], l.mx[i]);
    x.mx[i] = max(x.mx[i], r.mx[i]);
    x.mx[i] = max(x.mx[i], x.lmx[i]);
    x.mx[i] = max(x.mx[i], x.rmx[i]);
    x.mx[i] = max(x.mx[i], x.lmx[i]);
    x.mx[i] = max(x.mx[i], x.rmx[i]);
    x.mx[i] = max(x.mx[i], l.rmx[i] + r.lmax[i]);
    x.mx[i] = max(x.mx[i], r.lmx[i] + l.rmax[!i]);
    x.mx[i] = max(x.mx[i], l.rmax[!i] + r.lmax[i]);
  }
  updatemx(x);
}
void update(Node *x) { update(x->d, x->c[0]->d, x->c[1]->d); }
void pushdown(Data &x, Data &l, Data &r) {
  if (!x.flip) {
    return;
  }
  x.flip = false;
  l.flip ^= 1;
  r.flip ^= 1;
  for (auto *p : {&l, &r}) {
    swap(p->lmax[0], p->lmax[1]);
    swap(p->rmax[0], p->rmax[1]);
    swap(p->mx[0], p->mx[1]);
    swap(p->lmx[0], p->lmx[1]);
    swap(p->rmx[0], p->rmx[1]);
  }
  updatemx(x);
}
void pushdown(Node *x) { pushdown(x->d, x->c[0]->d, x->c[1]->d); }
Node *init(int l, int r) {
  Node *now = cur++;
  now->l = l;
  now->r = r;
  now->d.size = r - l + 1;
  if (l == r) {
    if (a[l] == '<') {
      now->d.lmax[0] = now->d.rmax[0] = 1;
    } else {
      now->d.lmax[1] = now->d.rmax[1] = 1;
    }
    return now;
  }
  int mid = l + r >> 1;
  now->c[0] = init(l, mid);
  now->c[1] = init(mid + 1, r);
  update(now);
  return now;
}
Data query(Node *x, int l, int r) {
  if (l <= x->l && x->r <= r) {
    x->d.flip ^= 1;
    swap(x->d.lmax[0], x->d.lmax[1]);
    swap(x->d.rmax[0], x->d.rmax[1]);
    swap(x->d.mx[0], x->d.mx[1]);
    swap(x->d.lmx[0], x->d.lmx[1]);
    swap(x->d.rmx[0], x->d.rmx[1]);
    updatemx(x->d);
    return x->d;
  }
  pushdown(x);
  int mid = x->l + x->r >> 1;
  Data res;
  if (r <= mid) {
    res = query(x->c[0], l, r);
  } else if (l > mid) {
    res = query(x->c[1], l, r);
  } else {
    auto ld = query(x->c[0], l, r);
    auto rd = query(x->c[1], l, r);
    res.size = ld.size + rd.size;
    update(res, ld, rd);
  }
  update(x);
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  cin >> (a + 1);
  auto root = init(1, n);
  while (m--) {
    int l, r;
    cin >> l >> r;
    auto res = query(root, l, r);
    int ans = res.mx[0];
    ans = max(ans, res.lmax[0]);
    ans = max(ans, res.rmax[1]);
    cout << ans << '\n';
  }
  return 0;
}