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;
const int MOD = (int)1e9 + 7;
const int FFTMOD = 119 << 23 | 1;
const int INF = (int)1e9 + 23111992;
const long long LINF = (long long)1e18 + 23111992;
const long double PI = acos((long double)-1);
const long double EPS = 1e-9;
inline long long gcd(long long a, long long b) {
  long long r;
  while (b) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
inline long long fpow(long long n, long long k, int p = MOD) {
  long long r = 1;
  for (; k; k >>= 1) {
    if (k & 1) r = r * n % p;
    n = n * n % p;
  }
  return r;
}
template <class T>
inline int chkmin(T& a, const T& val) {
  return val < a ? a = val, 1 : 0;
}
template <class T>
inline int chkmax(T& a, const T& val) {
  return a < val ? a = val, 1 : 0;
}
inline unsigned long long isqrt(unsigned long long k) {
  unsigned long long r = sqrt(k) + 1;
  while (r * r > k) r--;
  return r;
}
inline long long icbrt(long long k) {
  long long r = cbrt(k) + 1;
  while (r * r * r > k) r--;
  return r;
}
inline void addmod(int& a, int val, int p = MOD) {
  if ((a = (a + val)) >= p) a -= p;
}
inline void submod(int& a, int val, int p = MOD) {
  if ((a = (a - val)) < 0) a += p;
}
inline int mult(int a, int b, int p = MOD) { return (long long)a * b % p; }
inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }
inline int sign(long double x) { return x < -EPS ? -1 : x > +EPS; }
inline int sign(long double x, long double y) { return sign(x - y); }
mt19937 mt(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int mrand() { return abs((int)mt()); }
inline int mrand(int k) { return abs((int)mt()) % k; }
template <class num_t>
struct SegmentTree {
  struct node_t {
    num_t max[2];
    num_t pref[2];
    num_t suff[2];
    num_t pref2[2];
    num_t suff2[2];
    num_t lz;
    int size;
    node_t() {
      lz = 0;
      size = -1;
    }
  };
  int n;
  vector<node_t> st;
  void init(int n_) {
    n = n_;
    st.resize(n << 2);
  }
  node_t merge(node_t u, node_t v) {
    if (u.size == -1) return v;
    if (v.size == -1) return u;
    node_t c;
    for (int i = (0); i < (2); ++i) {
      c.max[i] = max(u.max[i], v.max[i]);
      c.pref[i] = u.pref[i];
      c.suff[i] = v.suff[i];
      c.pref2[i] = u.pref2[i];
      c.suff2[i] = v.suff2[i];
    }
    for (int i = (0); i < (2); ++i) {
      if (u.pref[i] == u.size) {
        c.pref[i] = u.pref[i] + v.pref[i];
      }
      if (v.suff[i] == v.size) {
        c.suff[i] = u.suff[i] + v.suff[i];
      }
      if (u.pref[i ^ 1] == u.size) {
        c.pref2[i] = u.pref[i ^ 1] + v.pref2[i];
      }
      if (v.suff[i ^ 1] == v.size) {
        c.suff2[i] = u.suff2[i] + v.suff[i ^ 1];
      }
      if (u.pref2[i] == u.size) {
        chkmax(c.pref2[i], u.pref2[i] + v.pref[i]);
      }
      if (v.suff2[i] == v.size) {
        chkmax(c.suff2[i], u.suff[i] + v.suff2[i]);
      }
    }
    for (int i = (0); i < (2); ++i) {
      chkmax(c.pref2[i], c.pref[i]);
      chkmax(c.suff2[i], c.suff[i]);
    }
    for (int i = (0); i < (2); ++i) {
      chkmax(c.max[i], c.pref[i]);
      chkmax(c.max[i], c.suff[i]);
      chkmax(c.max[i], c.pref2[i]);
      chkmax(c.max[i], c.suff2[i]);
      chkmax(c.max[i], u.suff[i] + v.pref2[i]);
      chkmax(c.max[i], u.suff2[i] + v.pref[i]);
    }
    c.size = u.size + v.size;
    return c;
  }
  void build(int p, int L, int R, vector<int>& a) {
    if (L == R) {
      st[p].max[0] = st[p].max[1] = 1;
      for (int i = (0); i < (2); ++i) {
        st[p].pref[i] = st[p].pref2[i] = (a[L] == i);
        st[p].suff[i] = st[p].suff2[i] = (a[R] != i);
      }
      st[p].size = 1;
      return;
    }
    build(p << 1, L, L + R >> 1, a);
    build(p << 1 | 1, (L + R >> 1) + 1, R, a);
    st[p] = merge(st[p << 1], st[p << 1 | 1]);
  }
  void push(int p, int L, int R) {
    if (st[p].lz) {
      swap(st[p].max[0], st[p].max[1]);
      swap(st[p].pref[0], st[p].pref[1]);
      swap(st[p].suff[0], st[p].suff[1]);
      swap(st[p].pref2[0], st[p].pref2[1]);
      swap(st[p].suff2[0], st[p].suff2[1]);
      if (L < R) {
        st[p << 1].lz ^= st[p].lz;
        st[p << 1 | 1].lz ^= st[p].lz;
      }
      st[p].lz = 0;
    }
  }
  void upd(int p, int l, int r, int L, int R, num_t val) {
    push(p, L, R);
    if (r < L || R < l) return;
    if (l <= L && R <= r) {
      st[p].lz = val;
      push(p, L, R);
      return;
    }
    upd(p << 1, l, r, L, L + R >> 1, val);
    upd(p << 1 | 1, l, r, (L + R >> 1) + 1, R, val);
    st[p] = merge(st[p << 1], st[p << 1 | 1]);
  }
  node_t query(int p, int l, int r, int L, int R) {
    push(p, L, R);
    if (r < L || R < l) return node_t();
    if (l <= L && R <= r) {
      return st[p];
    }
    return merge(query(p << 1, l, r, L, L + R >> 1),
                 query(p << 1 | 1, l, r, (L + R >> 1) + 1, R));
  }
  void upd(int l, int r, num_t val) { upd(1, l, r, 0, n - 1, val); }
  node_t query(int l, int r) { return query(1, l, r, 0, n - 1); }
};
SegmentTree<int> seg;
void chemthan() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<int> a(n);
  for (int i = (0); i < (n); ++i) a[i] = s[i] == '>';
  seg.init(n);
  seg.build(1, 0, n - 1, a);
  while (q--) {
    int l, r;
    cin >> l >> r;
    l--, r--;
    seg.upd(l, r, 1);
    cout << seg.query(l, r).max[0] << "\n";
  }
}
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(0), cin.tie(0);
  if (argc > 1) {
    assert(freopen(argv[1], "r", stdin));
  }
  if (argc > 2) {
    assert(freopen(argv[2], "wb", stdout));
  }
  chemthan();
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}