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("O3")
#pragma GCC target("sse4")
using namespace std;
template <class T>
bool ckmin(T& a, const T& b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001;
struct node {
  int L1, L2, R1, R2;
  bool Lt, Rt;
  int A1, A2;
  int S;
};
const node LP = {1, 0, 1, 0, true, true, 1, 1, 1};
const node RP = {1, 0, 1, 0, false, false, 1, 1, 1};
const node identity = {-1, -1, -1, -1, false, false, -1, -1, -1};
const long long SZ = 131072 * 4;
node sum[2 * SZ];
bool lazy[2 * SZ];
void print(node X) {
  cout << "Runs: " << X.L1 << " " << X.L2 << " " << X.R1 << " " << X.R2 << nl;
  cout << "Types: " << X.Lt << " " << X.Rt << nl;
  cout << "Ans: " << X.A1 << " " << X.A2 << nl;
  cout << "Size: " << X.S << nl;
}
node combine(node A, node B) {
  if (A.L1 < 0) return B;
  if (B.L1 < 0) return A;
  node res;
  res.Lt = A.Lt;
  res.Rt = B.Rt;
  if (A.L1 == A.S) {
    if (A.Lt == B.Lt) {
      res.L1 = A.L1 + B.L1;
      res.L2 = B.L2;
    } else {
      res.L1 = A.L1;
      res.L2 = B.L1;
    }
  } else if (A.L1 + A.L2 == A.S) {
    res.L1 = A.L1;
    res.L2 = A.L2;
    if (A.Lt != B.Lt) res.L2 += B.L1;
  } else {
    res.L1 = A.L1;
    res.L2 = A.L2;
  }
  if (B.R1 == B.S) {
    if (B.Rt == A.Rt) {
      res.R1 = B.R1 + A.R1;
      res.R2 = A.R2;
    } else {
      res.R1 = B.R1;
      res.R2 = A.R1;
    }
  } else if (B.R1 + B.R2 == B.S) {
    res.R1 = B.R1;
    res.R2 = B.R2;
    if (B.Rt != A.Rt) res.R2 += A.R1;
  } else {
    res.R1 = B.R1;
    res.R2 = B.R2;
  }
  res.S = A.S + B.S;
  res.A1 = max(A.A1, B.A1);
  res.A2 = max(A.A2, B.A2);
  if (A.Rt != B.Lt) {
    if (A.Rt) {
      ckmax(res.A1, A.R1 + B.L1);
    } else {
      ckmax(res.A2, A.R1 + B.L1);
    }
  } else {
    if (A.Rt) {
      ckmax(res.A2, A.R1 + A.R2 + B.L1);
      ckmax(res.A1, A.R1 + B.L1 + B.L2);
    } else {
      ckmax(res.A1, A.R1 + A.R2 + B.L1);
      ckmax(res.A2, A.R1 + B.L1 + B.L2);
    }
  }
  return res;
}
node flip(node A) {
  if (A.L1 < 0) return A;
  A.Lt = !A.Lt;
  A.Rt = !A.Rt;
  swap(A.A1, A.A2);
  return A;
}
void push(int index, long long L, long long R) {
  if (lazy[index]) {
    sum[index] = flip(sum[index]);
  }
  if (L != R && lazy[index])
    lazy[2 * index] = !lazy[2 * index],
             lazy[2 * index + 1] = !lazy[2 * index + 1];
  lazy[index] = false;
}
void pull(int index) {
  sum[index] = combine(sum[2 * index], sum[2 * index + 1]);
}
node query(int lo, int hi, int index = 1, long long L = 0,
           long long R = SZ - 1) {
  push(index, L, R);
  if (lo > R || L > hi) return identity;
  if (lo <= L && R <= hi) return sum[index];
  int M = (L + R) / 2;
  return combine(query(lo, hi, 2 * index, L, M),
                 query(lo, hi, 2 * index + 1, M + 1, R));
}
void update(int lo, int hi, int index = 1, long long L = 0,
            long long R = SZ - 1) {
  push(index, L, R);
  if (hi < L || R < lo) return;
  if (lo <= L && R <= hi) {
    lazy[index] = !lazy[index];
    push(index, L, R);
    return;
  }
  int M = (L + R) / 2;
  update(lo, hi, 2 * index, L, M);
  update(lo, hi, 2 * index + 1, M + 1, R);
  pull(index);
}
int solve(int lo, int hi) {
  update(lo, hi);
  node res = query(lo, hi);
  return res.A1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  for (int i = 0; i < (2 * SZ); i++) lazy[i] = false;
  for (int i = 0; i < (SZ); i++) {
    sum[i + SZ] = identity;
  }
  for (int i = 0; i < (N); i++) {
    if (S[i] == '>') {
      sum[i + SZ] = LP;
    } else {
      sum[i + SZ] = RP;
    }
  }
  for (int i = (SZ)-1; i >= 1; i--) {
    pull(i);
  }
  for (int i = 0; i < (Q); i++) {
    int L, R;
    cin >> L >> R;
    L--;
    R--;
    cout << solve(L, R) << nl;
  }
  return 0;
}