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 T>
void out(T x) {
  cout << x << endl;
  exit(0);
}
using ll = long long;
const ll mod = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 1e9;
int n, q;
string s;
char Flip(char c) {
  if (c == '>')
    c = '<';
  else
    c = '>';
  return c;
}
void better(int &x, int y) { x = max(x, y); }
int brute(int l, int r, bool flag) {
  if (flag) {
    for (int i = l; i <= r; i++) {
      s[i] = Flip(s[i]);
    }
  }
  vector<int> v(n + 2, 0);
  for (int i = l; i <= r; i++) {
    int x = i;
    while (true) {
      if (s[x] == '<') {
        if (x == 1 || s[x - 1] == '>') {
          v[x - 1]++;
          break;
        } else {
          x--;
        }
      }
      if (s[x] == '>') {
        if (x == n || s[x + 1] == '<') {
          v[x]++;
          break;
        } else {
          x++;
        }
      }
    }
  }
  return *max_element(v.begin(), v.end());
}
struct dat {
  int len;
  int res;
  int pref0, pref1;
  int suf0, suf1;
  int sinkl;
  int sinkr;
  dat() { len = res = pref0 = pref1 = suf0 = suf1 = sinkl = sinkr = 0; }
  dat(char c) {
    len = res = pref0 = pref1 = suf0 = suf1 = sinkl = sinkr = 0;
    len = 1;
    res = 1;
    if (c == '<') {
      pref0 = suf0 = 1;
    } else {
      pref1 = suf1 = 1;
    }
  }
};
dat merge(dat a, dat b) {
  dat x;
  x.len = a.len + b.len;
  if (a.len == a.pref0) {
    x.pref0 = a.len + b.pref0;
  } else {
    x.pref0 = a.pref0;
  }
  if (a.len == a.pref1) {
    x.pref1 = a.len + b.pref1;
  } else {
    x.pref1 = a.pref1;
  }
  if (b.len == b.suf0) {
    x.suf0 = a.suf0 + b.suf0;
  } else {
    x.suf0 = b.suf0;
  }
  if (b.len == b.suf1) {
    x.suf1 = a.suf1 + b.suf1;
  } else {
    x.suf1 = b.suf1;
  }
  x.sinkl = a.sinkl;
  if (a.len == a.pref1) better(x.sinkl, a.pref1 + b.pref0);
  if (a.len == a.pref1) better(x.sinkl, a.pref1 + b.sinkl);
  if (a.len == a.sinkl) better(x.sinkl, a.sinkl + b.pref0);
  x.sinkr = b.sinkr;
  if (b.len == b.pref0) better(x.sinkr, a.suf1 + b.pref0);
  if (b.len == b.sinkr) better(x.sinkr, a.suf1 + b.sinkr);
  if (b.len == b.suf0) better(x.sinkr, a.sinkr + b.suf0);
  x.res =
      max({a.res, b.res, x.pref0, x.pref1, x.suf0, x.suf1, x.sinkl, x.sinkr});
  better(x.res, a.suf1 + b.pref0);
  better(x.res, a.sinkr + b.pref0);
  better(x.res, a.suf1 + b.sinkl);
  return x;
}
struct node {
  dat v[2];
  node() { v[0] = v[1] = dat(); }
  node(char c) {
    v[0] = dat(c);
    v[1] = dat(Flip(c));
  }
  void flip() { swap(v[0], v[1]); }
};
node merge(node a, node b) {
  node x;
  for (int i = 0; i < 2; i++) {
    x.v[i] = merge(a.v[i], b.v[i]);
  }
  return x;
}
node t[4 * maxn];
bool o[4 * maxn];
void build(int v, int tl, int tr) {
  if (tl == tr) {
    t[v] = node(s[tl]);
  } else {
    int tm = (tl + tr) / 2;
    build(2 * v, tl, tm);
    build(2 * v + 1, tm + 1, tr);
    t[v] = merge(t[2 * v], t[2 * v + 1]);
  }
}
void push(int v) {
  if (!o[v]) return;
  t[2 * v].flip();
  t[2 * v + 1].flip();
  o[2 * v] = !o[2 * v];
  o[2 * v + 1] = !o[2 * v + 1];
  o[v] = false;
}
node qry(int v, int tl, int tr, int l, int r) {
  if (l > tr || r < tl) {
    return node();
  }
  if (l <= tl && tr <= r) {
    return t[v];
  }
  push(v);
  int tm = (tl + tr) / 2;
  return merge(qry(2 * v, tl, tm, l, r), qry(2 * v + 1, tm + 1, tr, l, r));
}
void flip(int v, int tl, int tr, int l, int r) {
  if (l > tr || r < tl) {
    return;
  }
  if (l <= tl && tr <= r) {
    t[v].flip();
    o[v] = !o[v];
    return;
  }
  push(v);
  int tm = (tl + tr) / 2;
  flip(2 * v, tl, tm, l, r);
  flip(2 * v + 1, tm + 1, tr, l, r);
  t[v] = merge(t[2 * v], t[2 * v + 1]);
}
const bool test = false;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  cin >> s;
  s = "." + s;
  build(1, 1, n);
  if (test) {
    for (int i = 1; i <= n; i++) {
      for (int j = i; j <= n; j++) {
        int q = qry(1, 1, n, i, j).v[0].res;
        int b = brute(i, j, false);
        assert(q == b);
      }
    }
    cout << "passed initial test" << endl;
  }
  while (q--) {
    int l, r;
    cin >> l >> r;
    flip(1, 1, n, l, r);
    int q = qry(1, 1, n, l, r).v[0].res;
    if (test) {
      int b = brute(l, r, true);
      cout << b << " was: " << q << endl;
      assert(q == b);
    }
    cout << q << "\n";
  }
  return 0;
}