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>
int max(int a, int b) { return a > b ? a : b; }
int h_, n_;
int sz[(1 << 19) * 2];
int ppl[(1 << 19) * 2], ppr[(1 << 19) * 2];
int qql[(1 << 19) * 2], qqr[(1 << 19) * 2];
int pplr[(1 << 19) * 2], pprl[(1 << 19) * 2];
int qqlr[(1 << 19) * 2], qqrl[(1 << 19) * 2];
int llr[(1 << 19) * 2], rrl[(1 << 19) * 2];
char lz[(1 << 19)];
void put(int i) {
  int tmp;
  tmp = ppl[i], ppl[i] = ppr[i], ppr[i] = tmp;
  tmp = qql[i], qql[i] = qqr[i], qqr[i] = tmp;
  tmp = pplr[i], pplr[i] = pprl[i], pprl[i] = tmp;
  tmp = qqlr[i], qqlr[i] = qqrl[i], qqrl[i] = tmp;
  tmp = llr[i], llr[i] = rrl[i], rrl[i] = tmp;
  if (i < n_) lz[i] ^= 1;
}
void pus(int i) {
  if (lz[i]) {
    put(i << 1), put(i << 1 | 1);
    lz[i] = 0;
  }
}
void pul(int i) {
  if (!lz[i]) {
    int l = i << 1, r = i << 1 | 1;
    ppl[i] = ppl[l] == sz[l] ? sz[l] + ppl[r] : ppl[l];
    ppr[i] = ppr[l] == sz[l] ? sz[l] + ppr[r] : ppr[l];
    qql[i] = qql[r] == sz[r] ? qql[l] + sz[r] : qql[r];
    qqr[i] = qqr[r] == sz[r] ? qqr[l] + sz[r] : qqr[r];
    pplr[i] = ppl[l] == sz[l] ? sz[l] + pplr[r]
                              : (pplr[l] == sz[l] ? sz[l] + ppr[r] : pplr[l]);
    pprl[i] = ppr[l] == sz[l] ? sz[l] + pprl[r]
                              : (pprl[l] == sz[l] ? sz[l] + ppl[r] : pprl[l]);
    qqlr[i] = qqr[r] == sz[r] ? qqlr[l] + sz[r]
                              : (qqlr[r] == sz[r] ? qql[l] + sz[r] : qqlr[r]);
    qqrl[i] = qql[r] == sz[r] ? qqrl[l] + sz[r]
                              : (qqrl[r] == sz[r] ? qqr[l] + sz[r] : qqrl[r]);
    llr[i] = max(max(llr[l], llr[r]), max(qqlr[l] + ppr[r], qql[l] + pplr[r]));
    rrl[i] = max(max(rrl[l], rrl[r]), max(qqrl[l] + ppl[r], qqr[l] + pprl[r]));
  }
}
void push(int i) {
  int h;
  for (h = h_; h > 0; h--) pus(i >> h);
}
void pull(int i) {
  while (i > 1) pul(i >>= 1);
}
void build(char *cc, int n) {
  int i;
  h_ = 0;
  while (1 << h_ < n) h_++;
  n_ = 1 << h_;
  for (i = 0; i < n_; i++) {
    if (i < n) {
      pplr[n_ + i] = pprl[n_ + i] = qqlr[n_ + i] = qqrl[n_ + i] = llr[n_ + i] =
          rrl[n_ + i] = 1;
      if (cc[i] == '<')
        ppl[n_ + i] = qql[n_ + i] = 1;
      else
        ppr[n_ + i] = qqr[n_ + i] = 1;
    }
    sz[n_ + i] = 1;
  }
  for (i = n_ - 1; i > 0; i--) {
    sz[i] = sz[i << 1] + sz[i << 1 | 1];
    pul(i);
  }
}
void update(int l, int r) {
  int l_ = l += n_, r_ = r += n_;
  push(l_), push(r_);
  for (; l <= r; l >>= 1, r >>= 1) {
    if ((l & 1) == 1) put(l++);
    if ((r & 1) == 0) put(r--);
  }
  pull(l_), pull(r_);
}
int query(int l, int r) {
  int qr, qrl, pl, prl, rl;
  push(l += n_), push(r += n_);
  qr = qrl = pl = prl = rl = 0;
  for (; l <= r; l >>= 1, r >>= 1) {
    if ((l & 1) == 1) {
      rl = max(max(rl, rrl[l]), max(qrl + ppl[l], qr + pprl[l]));
      qrl = qql[l] == sz[l] ? qrl + sz[l]
                            : (qqrl[l] == sz[l] ? qr + sz[l] : qqrl[l]);
      qr = qqr[l] == sz[l] ? qr + sz[l] : qqr[l];
      l++;
    }
    if ((r & 1) == 0) {
      rl = max(max(rl, rrl[r]), max(qqrl[r] + pl, qqr[r] + prl));
      prl = ppr[r] == sz[r] ? sz[r] + prl
                            : (pprl[r] == sz[r] ? sz[r] + pl : pprl[r]);
      pl = ppl[r] == sz[r] ? sz[r] + pl : ppl[r];
      r--;
    }
  }
  rl = max(rl, max(qrl + pl, qr + prl));
  return rl;
}
int main() {
  static char cc[500000 + 1];
  int n, q;
  scanf("%d%d%s", &n, &q, cc);
  build(cc, n);
  while (q--) {
    int l, r;
    scanf("%d%d", &l, &r), l--, r--;
    update(l, r);
    printf("%d\n", query(l, r));
  }
  return 0;
}