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;
template <typename T1, typename T2>
inline void chkmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chkmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
using ll = long long;
using ld = long double;
const string FILENAME = "input";
struct node {
  int len = 0;
  int zeroOne = 0;
  int oneZero = 0;
  int lCnt = 0;
  int lLen = 0;
  int lLen2 = 0;
  int rCnt = 0;
  int rLen = 0;
  int rLen2 = 0;
  int mod = 0;
  node() {}
  node(int a) {
    len = 1;
    lCnt = a;
    lLen = 1;
    rCnt = a;
    rLen = 1;
  }
  void flip() {
    swap(oneZero, zeroOne);
    lCnt ^= 1;
    rCnt ^= 1;
  }
};
node operator+(const node &a, const node &b) {
  node c;
  c.len = a.len + b.len;
  c.zeroOne = max(a.zeroOne, b.zeroOne);
  c.oneZero = max(a.oneZero, b.oneZero);
  if (a.rCnt == 0 && b.lCnt == 0) {
    chkmax(c.zeroOne, a.rLen + b.lLen + b.lLen2);
    chkmax(c.oneZero, a.rLen2 + a.rLen + b.lLen);
  }
  if (a.rCnt == 0 && b.lCnt == 1) {
    chkmax(c.zeroOne, a.rLen + b.lLen);
  }
  if (a.rCnt == 1 && b.lCnt == 0) {
    chkmax(c.oneZero, a.rLen + b.lLen);
  }
  if (a.rCnt == 1 && b.lCnt == 1) {
    chkmax(c.zeroOne, a.rLen2 + a.rLen + b.lLen);
    chkmax(c.oneZero, a.rLen + b.lLen + b.lLen2);
  }
  c.lCnt = a.lCnt;
  if (a.lLen == a.len) {
    if (b.lCnt == a.lCnt) {
      c.lLen = a.len + b.lLen;
      c.lLen2 = b.lLen2;
    } else {
      c.lLen = a.len;
      c.lLen2 = b.lLen;
    }
  } else {
    c.lLen = a.lLen;
    c.lLen2 = a.lLen2;
    if (a.lLen + a.lLen2 == a.len && b.lCnt == a.rCnt) {
      c.lLen2 += b.lLen;
    }
  }
  c.rCnt = b.rCnt;
  if (b.rLen == b.len) {
    if (b.rCnt == a.rCnt) {
      c.rLen = b.len + a.rLen;
      c.rLen2 = a.rLen2;
    } else {
      c.rLen = b.len;
      c.rLen2 = a.rLen;
    }
  } else {
    c.rLen = b.rLen;
    c.rLen2 = b.rLen2;
    if (b.rLen + b.rLen2 == b.len && a.rCnt == b.lCnt) {
      c.rLen2 += a.rLen;
    }
  }
  return c;
}
struct rmq {
  int ss = 1;
  vector<node> d;
  void init(vector<int> &st) {
    while (ss < (int)(st).size()) {
      ss <<= 1;
    }
    d.resize(2 * ss);
    for (int i = 0; i < (int)(st).size(); i++) {
      d[ss + i] = node(st[i]);
    }
    for (int i = ss - 1; i >= 1; i--) {
      d[i] = d[i * 2] + d[i * 2 + 1];
    }
  }
  void push(int v) {
    if (d[v].mod) {
      d[v].flip();
      d[v].mod = 0;
      if (v < ss) {
        d[v * 2].mod ^= 1;
        d[v * 2 + 1].mod ^= 1;
      }
    }
  }
  void add(int v, int vl, int vr, int l, int r) {
    if (vl > r || vr < l) {
      push(v);
      return;
    }
    if (l <= vl && vr <= r) {
      d[v].mod ^= 1;
      push(v);
      return;
    }
    push(v);
    add(v * 2, vl, (vl + vr) / 2, l, r);
    add(v * 2 + 1, (vl + vr) / 2 + 1, vr, l, r);
    d[v] = d[v * 2] + d[v * 2 + 1];
  }
  node get(int v, int vl, int vr, int l, int r) {
    if (vl > r || vr < l) {
      return node();
    }
    if (l <= vl && vr <= r) {
      push(v);
      return d[v];
    }
    push(v);
    return get(v * 2, vl, (vl + vr) / 2, l, r) +
           get(v * 2 + 1, (vl + vr) / 2 + 1, vr, l, r);
  }
  void flip(int l, int r) { add(1, 1, ss, l + 1, r + 1); }
  int get(int l, int r) {
    node ks = get(1, 1, ss, l + 1, r + 1);
    return max(max(ks.lLen, ks.rLen), ks.oneZero);
  }
} kek;
int get(int l, int r) {
  kek.flip(l, r);
  return kek.get(l, r);
}
int n, q;
string s;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  cin >> s;
  vector<int> st;
  for (int i = 0; i < n; i++) {
    st.push_back(s[i] == '>');
  }
  kek.init(st);
  for (int it = 0; it < q; it++) {
    int l, r;
    cin >> l >> r;
    l--, r--;
    cout << get(l, r) << '\n';
  }
  return 0;
}