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>
const int inf = 0x3f3f3f3f, Inf = 0x7fffffff;
const long long INF = 0x3f3f3f3f3f3f3f3f;
__inline__ __attribute__((always_inline)) unsigned int rnd() {
  static unsigned int seed = 416;
  return seed ^= seed >> 5, seed ^= seed << 17, seed ^= seed >> 13;
}
template <typename _Tp>
_Tp gcd(const _Tp &a, const _Tp &b) {
  return (!b) ? a : gcd(b, a % b);
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) _Tp abs(const _Tp &a) {
  return a >= 0 ? a : -a;
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) _Tp max(const _Tp &a, const _Tp &b) {
  return a < b ? b : a;
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) _Tp min(const _Tp &a, const _Tp &b) {
  return a < b ? a : b;
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) void chmax(_Tp &a, const _Tp &b) {
  (a < b) && (a = b);
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) void chmin(_Tp &a, const _Tp &b) {
  (b < a) && (a = b);
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) void read(_Tp &x) {
  char ch(getchar());
  bool f(false);
  while (ch < 48 || ch > 57) f |= ch == 45, ch = getchar();
  x = ch & 15, ch = getchar();
  while (ch >= 48 && ch <= 57)
    x = (((x << 2) + x) << 1) + (ch & 15), ch = getchar();
  if (f) x = -x;
}
template <typename _Tp, typename... Args>
__inline__ __attribute__((always_inline)) void read(_Tp &t, Args &...args) {
  read(t);
  read(args...);
}
__inline__ __attribute__((always_inline)) int read_str(char *s) {
  char ch(getchar());
  while (ch == ' ' || ch == '\r' || ch == '\n') ch = getchar();
  char *tar = s;
  *tar = ch, ch = getchar();
  while (ch != ' ' && ch != '\r' && ch != '\n' && ch != EOF)
    *(++tar) = ch, ch = getchar();
  return tar - s + 1;
}
const int N = 500005;
struct node {
  int L1, L2;
  int R1, R2;
  int La1, La2;
  int Ra1, Ra2;
  int ans1, ans2;
  int l, r;
  __inline__ __attribute__((always_inline)) node operator+(
      const node &o) const {
    node c;
    c.L1 = L1 == r - l + 1 ? L1 + o.L1 : L1;
    c.R1 = o.R1 == o.r - o.l + 1 ? o.R1 + R1 : o.R1;
    c.L2 = L2 == r - l + 1 ? L2 + o.L2 : L2;
    c.R2 = o.R2 == o.r - o.l + 1 ? o.R2 + R2 : o.R2;
    c.La1 =
        La1 == r - l + 1 ? (L2 == r - l + 1 ? La1 + o.La1 : La1 + o.L1) : La1;
    c.La2 =
        La2 == r - l + 1 ? (L1 == r - l + 1 ? La2 + o.La2 : La2 + o.L2) : La2;
    c.Ra1 = o.Ra1 == o.r - o.l + 1
                ? (o.R1 == o.r - o.l + 1 ? o.Ra1 + Ra1 : o.Ra1 + R2)
                : o.Ra1;
    c.Ra2 = o.Ra2 == o.r - o.l + 1
                ? (o.R2 == o.r - o.l + 1 ? o.Ra2 + Ra2 : o.Ra2 + R1)
                : o.Ra2;
    c.ans1 = max(max(ans1, o.ans1), max(Ra1 + o.L1, o.La1 + R2));
    c.ans2 = max(max(ans2, o.ans2), max(Ra2 + o.L2, o.La2 + R1));
    c.l = l, c.r = o.r;
    return c;
  }
  __inline__ __attribute__((always_inline)) void flip() {
    std::swap(L1, L2);
    std::swap(R1, R2);
    std::swap(La1, La2);
    std::swap(Ra1, Ra2);
    std::swap(ans1, ans2);
  }
};
char s[N];
struct seg_tr {
  struct Node {
    int ls, rs;
    node val;
    bool tag;
  } f[N << 1];
  int node_cnt;
  __inline__ __attribute__((always_inline)) void PushUp(int x) {
    f[x].val = f[f[x].ls].val + f[f[x].rs].val;
  }
  int build(int l, int r) {
    int cur = ++node_cnt;
    if (l == r) {
      if (s[l] == '<')
        f[cur].val = (node){1, 0, 1, 0, 1, 1, 1, 1, 1, 1, l, l};
      else
        f[cur].val = (node){0, 1, 0, 1, 1, 1, 1, 1, 1, 1, l, l};
      return cur;
    }
    int mid = (l + r) >> 1;
    f[cur].ls = build(l, mid);
    f[cur].rs = build(mid + 1, r);
    PushUp(cur);
    return cur;
  }
  __inline__ __attribute__((always_inline)) void flip(int cur) {
    f[cur].tag ^= 1;
    f[cur].val.flip();
  }
  __inline__ __attribute__((always_inline)) void PushDown(int cur) {
    if (f[cur].tag) {
      flip(f[cur].ls);
      flip(f[cur].rs);
      f[cur].tag = 0;
    }
  }
  void Update(int L, int R, int l, int r, int cur) {
    if (L <= l && r <= R) {
      flip(cur);
      return;
    }
    PushDown(cur);
    int mid = (l + r) >> 1;
    if (L <= mid) Update(L, R, l, mid, f[cur].ls);
    if (R > mid) Update(L, R, mid + 1, r, f[cur].rs);
    PushUp(cur);
  }
  node Query(int L, int R, int l, int r, int cur) {
    if (L <= l && r <= R) return f[cur].val;
    PushDown(cur);
    int mid = (l + r) >> 1;
    if (L <= mid && R > mid)
      return Query(L, R, l, mid, f[cur].ls) +
             Query(L, R, mid + 1, r, f[cur].rs);
    return L <= mid ? Query(L, R, l, mid, f[cur].ls)
                    : Query(L, R, mid + 1, r, f[cur].rs);
  }
} tr;
int main() {
  int n, q;
  read(n, q);
  read_str(s + 1);
  tr.build(1, n);
  while (q--) {
    int l, r;
    read(l, r);
    tr.Update(l, r, 1, n, 1);
    printf("%d\n", tr.Query(l, r, 1, n, 1).ans1);
  }
  return 0;
}