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>
long long dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
long long dy[8] = {1, 0, -1, 0, -1, 1, 1, -1};
using namespace std;
class pa3 {
 public:
  long long x;
  long long y, z;
  pa3(long long x = 0, long long y = 0, long long z = 0) : x(x), y(y), z(z) {}
  bool operator<(const pa3 &p) const {
    if (x != p.x) return x < p.x;
    if (y != p.y) return y < p.y;
    return z < p.z;
  }
  bool operator>(const pa3 &p) const {
    if (x != p.x) return x > p.x;
    if (y != p.y) return y > p.y;
    return z > p.z;
  }
  bool operator==(const pa3 &p) const {
    return x == p.x && y == p.y && z == p.z;
  }
  bool operator!=(const pa3 &p) const {
    return !(x == p.x && y == p.y && z == p.z);
  }
};
class pa4 {
 public:
  long long x;
  long long y, z, w;
  pa4(long long x = 0, long long y = 0, long long z = 0, long long w = 0)
      : x(x), y(y), z(z), w(w) {}
  bool operator<(const pa4 &p) const {
    if (x != p.x) return x < p.x;
    if (y != p.y) return y < p.y;
    if (z != p.z) return z < p.z;
    return w < p.w;
  }
  bool operator>(const pa4 &p) const {
    if (x != p.x) return x > p.x;
    if (y != p.y) return y > p.y;
    if (z != p.z) return z > p.z;
    return w > p.w;
  }
  bool operator==(const pa4 &p) const {
    return x == p.x && y == p.y && z == p.z && w == p.w;
  }
};
class pa2 {
 public:
  long long x, y;
  pa2(long long x = 0, long long y = 0) : x(x), y(y) {}
  pa2 operator+(pa2 p) { return pa2(x + p.x, y + p.y); }
  pa2 operator-(pa2 p) { return pa2(x - p.x, y - p.y); }
  bool operator<(const pa2 &p) const { return y != p.y ? y < p.y : x < p.x; }
  bool operator>(const pa2 &p) const { return x != p.x ? x < p.x : y < p.y; }
  bool operator==(const pa2 &p) const {
    return abs(x - p.x) == 0 && abs(y - p.y) == 0;
  }
  bool operator!=(const pa2 &p) const {
    return !(abs(x - p.x) == 0 && abs(y - p.y) == 0);
  }
};
string itos(long long i) {
  ostringstream s;
  s << i;
  return s.str();
}
long long Gcd(long long v, long long b) {
  if (v == 0) return b;
  if (b == 0) return v;
  if (v > b) return Gcd(b, v);
  if (v == b) return b;
  if (b % v == 0) return v;
  return Gcd(v, b % v);
}
long long mod;
long long extgcd(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long d = extgcd(b, a % b, y, x);
  y -= a / b * x;
  return d;
}
pair<long long, long long> operator+(const pair<long long, long long> &l,
                                     const pair<long long, long long> &r) {
  return {l.first + r.first, l.second + r.second};
}
pair<long long, long long> operator-(const pair<long long, long long> &l,
                                     const pair<long long, long long> &r) {
  return {l.first - r.first, l.second - r.second};
}
long long beki(long long wa, long long rr, long long warukazu) {
  if (rr == 0) return 1 % warukazu;
  if (rr == 1) return wa % warukazu;
  wa %= warukazu;
  if (rr % 2 == 1)
    return ((long long)beki(wa, rr - 1, warukazu) * (long long)wa) % warukazu;
  long long zx = beki(wa, rr / 2, warukazu);
  return (zx * zx) % warukazu;
}
long long pr[10];
long long inv[10];
long long comb(long long nn, long long rr) {
  if (rr < 0 || rr > nn || nn < 0) return 0;
  long long r = pr[nn] * inv[rr];
  r %= mod;
  r *= inv[nn - rr];
  r %= mod;
  return r;
}
void gya(long long ert) {
  pr[0] = 1;
  for (long long i = 1; i <= ert; i++) {
    pr[i] = ((long long)pr[i - 1] * i) % mod;
  }
  inv[ert] = beki(pr[ert], mod - 2, mod);
  for (long long i = ert - 1; i >= 0; i--) {
    inv[i] = (long long)inv[i + 1] * (i + 1) % mod;
  }
}
struct hoge {
  bool l;
  bool r;
  long long sz;
  array<long long, 3> a;
};
hoge mer(hoge x, hoge y) {
  if (x.sz == 0) return y;
  if (y.sz == 0) return x;
  long long t[6] = {};
  long long sz = x.sz + y.sz;
  for (long long i = 0; i < x.sz; i++) t[i] = x.a[i];
  if (x.r && y.l) {
    for (long long i = 0; i < y.sz; i++) t[i + x.sz] = y.a[i];
  } else {
    for (long long i = 0; i < y.sz; i++) t[i + x.sz - 1] += y.a[i];
    sz--;
  }
  array<long long, 3> a;
  if (sz <= 3)
    for (long long i = 0; i < sz; i++) a[i] = t[i];
  else {
    a[0] = t[0];
    long long g = -1000000007;
    for (long long i = 1; i < sz - 1; i++) g = max(g, t[i]);
    a[1] = g;
    a[2] = t[sz - 1];
    sz = 3;
  }
  return {x.l, y.r, sz, a};
}
vector<hoge> ura;
hoge uni;
struct seg {
 private:
 public:
  long long cor = (1 << 19);
  const long long inff = 1000000007 * 1000000ll;
  vector<hoge> vec;
  vector<long long> lazy;
  void shoki1() {
    vec.resize(2 * cor + 3, uni);
    lazy.resize(2 * cor + 3, false);
    ura.resize(2 * cor + 3, uni);
  }
  void shoki2() {
    for (long long i = cor - 1; i > 0; i--)
      vec[i] = mer(vec[2 * i], vec[2 * i + 1]),
      ura[i] = mer(ura[2 * i], ura[2 * i + 1]);
  }
  hoge chien(long long k, long long len) {
    if (!lazy[k]) return vec[k];
    if (k < cor) {
      swap(vec[k], ura[k]);
      lazy[2 * k] ^= 1;
      lazy[2 * k + 1] ^= 1;
      lazy[k] = 0;
    } else {
      swap(vec[k], ura[k]);
      lazy[k] = 0;
    }
    return vec[k];
  }
  void clear_chien(long long r) {
    if (r == 0) return;
    long long f = 31 - __builtin_clz(r);
    long long pos = 0;
    long long len = cor;
    for (long long i = f; i >= 0; i--) {
      pos *= 2;
      pos += !!(r & (1 << i));
      chien(pos, len);
      len /= 2;
    }
  }
  void rangeupd(long long a, long long b) {
    a += cor, b += cor;
    long long aa = a / (a & (-a)) / 2;
    long long bb = b / (b & (-b)) / 2;
    long long lenaa = 2 * (a & -a);
    long long lenbb = 2 * (b & -b);
    while (a < b) {
      if (a & 1) {
        lazy[a] ^= 1;
        a++;
      }
      if (b & 1) {
        b--;
        lazy[b] ^= 1;
      }
      a /= 2, b /= 2;
    }
    while (aa > 0 || bb > 0) {
      if (aa > bb) {
        vec[aa] = mer(chien(2 * aa, lenaa / 2), chien(2 * aa + 1, lenaa / 2));
        ura[aa] = mer(ura[2 * aa], ura[2 * aa + 1]);
        aa /= 2;
        lenaa *= 2;
      } else if (aa < bb) {
        vec[bb] = mer(chien(2 * bb, lenbb / 2), chien(2 * bb + 1, lenbb / 2));
        ura[bb] = mer(ura[2 * bb], ura[2 * bb + 1]);
        bb /= 2;
        lenbb *= 2;
      } else {
        vec[aa] = mer(chien(2 * aa, lenaa / 2), chien(2 * aa + 1, lenaa / 2));
        ura[aa] = mer(ura[2 * aa], ura[2 * aa + 1]);
        aa /= 2;
        lenaa *= 2;
        bb = aa, lenbb = lenaa;
      }
    }
  }
  hoge getmin(long long a, long long b) {
    a += cor, b += cor;
    long long aa = a / (a & (-a)) / 2;
    long long bb = b / (b & (-b)) / 2;
    clear_chien(aa);
    clear_chien(bb);
    long long len = 1;
    hoge hi = uni, mi = uni;
    while (a < b) {
      if (a & 1) {
        hi = mer(hi, chien(a, len));
        a++;
      }
      if (b & 1) {
        b--;
        mi = mer(chien(b, len), mi);
      }
      a /= 2, b /= 2, len *= 2;
    }
    return mer(hi, mi);
  }
};
hoge migi, hidari;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  uni.sz = 0;
  migi.l = 1, migi.r = 0, migi.sz = 1;
  migi.a[0] = 1;
  hidari.r = 1, hidari.l = 0, hidari.sz = 1;
  hidari.a[0] = 1;
  long long n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  s = " " + s;
  seg ss;
  ss.shoki1();
  for (long long i = 1; i <= n; i++) {
    if (s[i] == '>') {
      ss.vec[ss.cor + i] = migi;
      ura[ss.cor + i] = hidari;
    } else {
      ss.vec[ss.cor + i] = hidari;
      ura[ss.cor + i] = migi;
    }
  }
  ss.shoki2();
  for (long long er = 0; er < q; er++) {
    long long l, r;
    cin >> l >> r;
    r++;
    ss.rangeupd(l, r);
    hoge z = ss.getmin(l, r);
    long long ans = -1;
    for (long long i = 0; i < z.sz; i++) ans = max(ans, z.a[i]);
    cout << ans << endl;
  }
  return 0;
}