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 maxm = 500010;
struct Node {
  int le, ri;
  int ll, lr, rl, rr;
  int lmax1, lmax2, rmax1, rmax2, max1, max2;
  bool tag;
  explicit Node(int le = 0, int ri = 0, int ll = 0, int lr = 0, int rl = 0,
                int rr = 0, int lmax1 = 0, int lmax2 = 0, int rmax1 = 0,
                int rmax2 = 0, int max1 = 0, int max2 = 0, bool tag = false)
      : le(le),
        ri(ri),
        ll(ll),
        lr(lr),
        rl(rl),
        rr(rr),
        lmax1(lmax1),
        lmax2(lmax2),
        rmax1(rmax1),
        rmax2(rmax2),
        max1(max1),
        max2(max2),
        tag(tag){};
  void setSingleLeft() {
    ll = rl = lmax1 = lmax2 = max1 = max2 = rmax1 = rmax2 = 1;
  }
  void setSingleRight() {
    lr = rr = lmax1 = lmax2 = max1 = max2 = rmax1 = rmax2 = 1;
  }
} nodes[maxm << 3];
char c;
void swap(Node& x) {
  swap(x.ll, x.lr);
  swap(x.rl, x.rr);
  swap(x.lmax1, x.lmax2);
  swap(x.rmax1, x.rmax2);
  swap(x.max1, x.max2);
}
Node merge(Node x, Node y) {
  if (x.tag) {
    x.tag = false;
    swap(x);
  }
  if (y.tag) {
    y.tag = false;
    swap(y);
  }
  bool allxll = (x.ll == x.ri - x.le), allxlr = (x.lr == x.ri - x.le),
       allyrr = (y.rr == y.ri - y.le), allyrl = (y.rl == y.ri - y.le);
  return Node(x.le, y.ri, allxll ? x.ll + y.ll : x.ll,
              allxlr ? x.lr + y.lr : x.lr, allyrl ? x.rl + y.rl : y.rl,
              allyrr ? x.rr + y.rr : y.rr,
              max(x.lmax1 + (x.lmax1 == x.ri - x.le ? y.ll : 0),
                  allxlr ? x.lr + y.lmax1 : 0),
              max(x.lmax2 + (x.lmax2 == x.ri - x.le ? y.lr : 0),
                  allxll ? x.ll + y.lmax2 : 0),
              max(y.rmax1 + (y.rmax1 == y.ri - y.le ? x.rr : 0),
                  allyrl ? x.rmax1 + y.rl : 0),
              max(y.rmax2 + (y.rmax2 == y.ri - y.le ? x.rl : 0),
                  allyrr ? x.rmax2 + y.rr : 0),
              max({x.max1, y.max1, x.rmax1 + y.ll, y.lmax1 + x.rr}),
              max({x.max2, y.max2, x.rmax2 + y.lr, y.lmax2 + x.rl}));
}
void pushdown(int now) {
  if (nodes[now].tag) {
    nodes[now].tag = 0;
    nodes[(now << 1)].tag ^= 1, nodes[(now << 1 | 1)].tag ^= 1;
    swap(nodes[now]);
  }
}
void modify(int now, int le, int ri) {
  if (le == nodes[now].le && ri == nodes[now].ri)
    nodes[now].tag ^= 1;
  else {
    pushdown(now);
    if (le >= ((nodes[now].le + nodes[now].ri) >> 1))
      modify((now << 1 | 1), le, ri);
    else if (ri <= ((nodes[now].le + nodes[now].ri) >> 1))
      modify((now << 1), le, ri);
    else {
      modify((now << 1), le, ((nodes[now].le + nodes[now].ri) >> 1));
      modify((now << 1 | 1), ((nodes[now].le + nodes[now].ri) >> 1), ri);
    }
    nodes[now] = merge(nodes[(now << 1)], nodes[(now << 1 | 1)]);
  }
}
void init(int now, int le, int ri) {
  nodes[now].le = le, nodes[now].ri = ri;
  if (le + 1 == ri) {
    cin >> c;
    if (c == '<')
      nodes[now].setSingleLeft();
    else
      nodes[now].setSingleRight();
  } else {
    init((now << 1), le, ((nodes[now].le + nodes[now].ri) >> 1));
    init((now << 1 | 1), ((nodes[now].le + nodes[now].ri) >> 1), ri);
    nodes[now] = merge(nodes[(now << 1)], nodes[(now << 1 | 1)]);
  }
}
Node ask(int now, int le, int ri) {
  pushdown(now);
  if (le == nodes[now].le && ri == nodes[now].ri)
    return nodes[now];
  else {
    if (le >= ((nodes[now].le + nodes[now].ri) >> 1))
      return ask((now << 1 | 1), le, ri);
    else if (ri <= ((nodes[now].le + nodes[now].ri) >> 1))
      return ask((now << 1), le, ri);
    else
      return merge(
          ask((now << 1), le, ((nodes[now].le + nodes[now].ri) >> 1)),
          ask((now << 1 | 1), ((nodes[now].le + nodes[now].ri) >> 1), ri));
  }
}
int n, m;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  init(1, 1, n + 1);
  for (int i = 1, l, r; i <= m; ++i) {
    cin >> l >> r;
    modify(1, l, r + 1);
    auto res = ask(1, l, r + 1);
    cout << (res.tag ? res.max2 : res.max1) << "\n";
  }
  return 0;
}