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>
#pragma GCC optimize("Ofast", "unroll-loops", "omit-frame-pointer", "inline")
#pragma GCC option("arch=native", "tune=native", "no-zero-upper")
#pragma GCC target("avx2", "popcnt", "rdrnd", "bmi2")
using namespace std;
const int LIM = 1 << 20;
int przedzial[LIM];
int prefiks[LIM];
int sufiks[LIM];
int prefiks_zer[LIM];
int prefiks_jedynek[LIM];
int sufiks_zer[LIM];
int sufiks_jedynek[LIM];
int rozmiar[LIM];
int przedzial2[LIM];
int sufiks2[LIM];
int prefiks2[LIM];
int lazy[LIM];
int N = 1;
vector<pair<int, int>> V;
void licz(int i) {
  rozmiar[i] = rozmiar[2 * i] + rozmiar[2 * i + 1];
  prefiks_zer[i] = prefiks_zer[2 * i];
  if (prefiks_zer[2 * i] == rozmiar[2 * i]) {
    prefiks_zer[i] += prefiks_zer[2 * i + 1];
  }
  prefiks_jedynek[i] = prefiks_jedynek[2 * i];
  if (prefiks_jedynek[2 * i] == rozmiar[2 * i]) {
    prefiks_jedynek[i] += prefiks_jedynek[2 * i + 1];
  }
  sufiks_zer[i] = sufiks_zer[2 * i + 1];
  if (sufiks_zer[2 * i + 1] == rozmiar[2 * i + 1]) {
    sufiks_zer[i] += sufiks_zer[2 * i];
  }
  sufiks_jedynek[i] = sufiks_jedynek[2 * i + 1];
  if (sufiks_jedynek[2 * i + 1] == rozmiar[2 * i + 1]) {
    sufiks_jedynek[i] += sufiks_jedynek[2 * i];
  }
  prefiks[i] = prefiks[2 * i];
  if (prefiks[2 * i] == rozmiar[2 * i]) {
    prefiks[i] += prefiks_jedynek[2 * i + 1];
  }
  if (prefiks_zer[2 * i] == rozmiar[2 * i]) {
    prefiks[i] = max(prefiks[i], prefiks_zer[2 * i] + prefiks[2 * i + 1]);
  }
  sufiks[i] = sufiks[2 * i + 1];
  if (sufiks[2 * i + 1] == rozmiar[2 * i + 1]) {
    sufiks[i] += sufiks_zer[2 * i];
  }
  if (sufiks_jedynek[2 * i + 1] == rozmiar[2 * i + 1]) {
    sufiks[i] = max(sufiks[i], sufiks_jedynek[2 * i + 1] + sufiks[2 * i]);
  }
  przedzial[i] = max(przedzial[2 * i], przedzial[2 * i + 1]);
  przedzial[i] = max(przedzial[i], sufiks[2 * i] + prefiks_jedynek[2 * i + 1]);
  przedzial[i] = max(przedzial[i], sufiks_zer[2 * i] + prefiks[2 * i + 1]);
  prefiks2[i] = prefiks2[2 * i];
  if (prefiks2[2 * i] == rozmiar[2 * i]) {
    prefiks2[i] += prefiks_zer[2 * i + 1];
  }
  if (prefiks_jedynek[2 * i] == rozmiar[2 * i]) {
    prefiks2[i] =
        max(prefiks2[i], prefiks_jedynek[2 * i] + prefiks2[2 * i + 1]);
  }
  sufiks2[i] = sufiks2[2 * i + 1];
  if (sufiks2[2 * i + 1] == rozmiar[2 * i + 1]) {
    sufiks2[i] += sufiks_jedynek[2 * i];
  }
  if (sufiks_zer[2 * i + 1] == rozmiar[2 * i + 1]) {
    sufiks2[i] = max(sufiks2[i], sufiks_zer[2 * i + 1] + sufiks2[2 * i]);
  }
  przedzial2[i] = max(przedzial2[2 * i], przedzial2[2 * i + 1]);
  przedzial2[i] = max(przedzial2[i], sufiks2[2 * i] + prefiks_zer[2 * i + 1]);
  przedzial2[i] =
      max(przedzial2[i], sufiks_jedynek[2 * i] + prefiks2[2 * i + 1]);
}
void spl(int v) {
  lazy[2 * v] ^= lazy[v];
  swap(prefiks_zer[2 * v], prefiks_jedynek[2 * v]);
  swap(sufiks_zer[2 * v], sufiks_jedynek[2 * v]);
  swap(prefiks[2 * v], prefiks2[2 * v]);
  swap(sufiks[2 * v], sufiks2[2 * v]);
  swap(przedzial[2 * v], przedzial2[2 * v]);
  lazy[2 * v + 1] ^= lazy[v];
  swap(prefiks_zer[2 * v + 1], prefiks_jedynek[2 * v + 1]);
  swap(sufiks_zer[2 * v + 1], sufiks_jedynek[2 * v + 1]);
  swap(prefiks[2 * v + 1], prefiks2[2 * v + 1]);
  swap(sufiks[2 * v + 1], sufiks2[2 * v + 1]);
  swap(przedzial[2 * v + 1], przedzial2[2 * v + 1]);
  lazy[v] = 0;
}
void upd(int v, int l, int r, int a, int b) {
  if (b < l || a > r) return;
  if (a <= l && r <= b) {
    V.push_back({l, v});
    lazy[v] ^= 1;
    swap(prefiks_zer[v], prefiks_jedynek[v]);
    swap(sufiks_zer[v], sufiks_jedynek[v]);
    swap(prefiks[v], prefiks2[v]);
    swap(sufiks[v], sufiks2[v]);
    swap(przedzial[v], przedzial2[v]);
    return;
  }
  if (lazy[v]) spl(v);
  int mid = (l + r) / 2;
  upd(2 * v, l, mid, a, b);
  upd(2 * v + 1, mid + 1, r, a, b);
  licz(v);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  while (N < n) N *= 2;
  for (int i = 0; i < (n); ++i) {
    char a;
    cin >> a;
    przedzial[N + i] = prefiks[N + i] = sufiks[N + i] = rozmiar[N + i] = 1;
    przedzial2[N + i] = sufiks2[N + i] = prefiks2[N + i] = 1;
    if (a == '<') {
      prefiks_jedynek[N + i] = 1;
      sufiks_jedynek[N + i] = 1;
    } else {
      prefiks_zer[N + i] = 1;
      sufiks_zer[N + i] = 1;
    }
  }
  for (int i = N - 1; i >= 0; --i) licz(i);
  while (q--) {
    int l, r;
    cin >> l >> r;
    --l;
    --r;
    V.clear();
    upd(1, 0, N - 1, l, r);
    sort(V.begin(), V.end());
    vector<int> zera(V.size()), jedynki(V.size());
    int ans = 0;
    for (int i = 0; i < (V.size()); ++i) {
      ans = max(ans, przedzial[V[i].second]);
      zera[i] = sufiks_zer[V[i].second];
      if (sufiks_zer[V[i].second] == rozmiar[V[i].second] && i)
        zera[i] += zera[i - 1];
    }
    for (int i = V.size() - 1; i >= 0; --i) {
      jedynki[i] = prefiks_jedynek[V[i].second];
      if (prefiks_jedynek[V[i].second] == rozmiar[V[i].second] &&
          i < V.size() - 1)
        jedynki[i] += jedynki[i + 1];
    }
    for (int i = 0; i < (V.size()); ++i) {
      int akt = prefiks[V[i].second];
      if (i) akt += zera[i - 1];
      ans = max(ans, akt);
      akt = sufiks[V[i].second];
      if (i < V.size() - 1) akt += jedynki[i + 1];
      ans = max(ans, akt);
      if (przedzial[V[i].second] < rozmiar[V[i].second]) continue;
      akt = przedzial[V[i].second];
      if (i) akt += zera[i - 1];
      if (i < V.size() - 1) akt += jedynki[i + 1];
      ans = max(ans, akt);
    }
    cout << ans << '\n';
  }
}