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;
using namespace std;
const int maxn = 500000 + 10;
const int maxm = 2000 + 10;
struct node {
  int lr, ll, rr, rl, maxv, same;
  void clear() { lr = ll = rr = rl = maxv = same = 0; }
  void print() {
    fprintf(
        stderr,
        "left >: %d , left <: %d , right >: %d , right <: %d , Maxv: %d  %s\n",
        lr, ll, rr, rl, maxv, same ? "same" : "not same");
  }
};
char s[maxn];
node merge(const node& a, const node& b) {
  node c;
  if (a.maxv == 0 || b.maxv == 0) {
    c = a.maxv == 0 ? b : a;
    return c;
  }
  c.maxv = max(a.maxv, b.maxv);
  c.lr = a.lr, c.ll = a.ll;
  c.rl = b.rl, c.rr = b.rr;
  c.same = 1;
  if (a.rl == 0) {
    if (b.lr == 0) {
      c.maxv = max(c.maxv, b.ll + a.rr);
      if (a.same) {
        c.ll = b.ll;
      }
      if (b.same) {
        c.rr = a.rr;
      }
      c.same = b.same & a.same;
    } else {
      int tmp = a.rr + b.lr + b.ll;
      if (a.same) {
        c.lr += b.lr;
        c.ll += b.ll;
      }
      if (b.same) {
        c.rr += a.rr;
      }
      c.maxv = max(c.maxv, tmp);
      if (!a.same || !b.same) c.same = 0;
    }
  } else {
    if (b.lr == 0) {
      assert(b.ll != 0);
      c.maxv = max(c.maxv, a.rl + a.rr + b.ll);
      if (b.same) {
        c.rl += a.rl;
        c.rr += a.rr;
      }
      if (a.same) {
        c.ll += b.ll;
        c.lr += b.lr;
      }
      if (!a.same || !b.same) c.same = 0;
    } else {
      c.same = 0;
    }
  }
  if (c.same) {
    assert(c.lr == c.rr);
    assert(c.ll == c.rl);
  }
  return c;
}
struct segtree {
  node a[maxn << 2];
  node inv[maxn << 2];
  int flip[maxn << 2];
  int n, ql, qr;
  node ans;
  void init(int N) {
    n = N;
    build(1, n, 1);
  }
  void maintain(int l, int r, int o) {
    if (l != r) {
      a[o] = merge(a[o << 1], a[o << 1 | 1]);
      inv[o] = merge(inv[o << 1], inv[o << 1 | 1]);
    }
  }
  void build(int l, int r, int o) {
    flip[o] = 0;
    if (l == r) {
      node& x = a[o];
      node& y = inv[o];
      if (s[l] == '>') {
        x.same = 1;
        x.lr = 1;
        x.ll = 0;
        x.rr = 1;
        x.rl = 0;
        x.maxv = 1;
        y.same = 1;
        y.lr = 0;
        y.ll = 1;
        y.rr = 0;
        y.rl = 1;
        y.maxv = 1;
      } else {
        x.same = 1;
        x.lr = 0;
        x.ll = 1;
        x.rr = 0;
        x.rl = 1;
        x.maxv = 1;
        y.same = 1;
        y.lr = 1;
        y.ll = 0;
        y.rr = 1;
        y.rl = 0;
        y.maxv = 1;
      }
      return;
    }
    int mid = l + r >> 1;
    build(l, mid, o << 1), build(mid + 1, r, o << 1 | 1);
    maintain(l, r, o);
  }
  void pushdown(int l, int r, int o) {
    if (flip[o]) {
      flip[o << 1] ^= 1;
      flip[o << 1 | 1] ^= 1;
      swap(inv[o << 1], a[o << 1]);
      swap(inv[o << 1 | 1], a[o << 1 | 1]);
    }
    flip[o] = 0;
  }
  void update(int l, int r, int o) {
    if (ql <= l && qr >= r) {
      flip[o] ^= 1;
      swap(inv[o], a[o]);
      return;
    } else {
      int mid = l + r >> 1;
      pushdown(l, r, o);
      if (ql <= mid) update(l, mid, o << 1);
      if (qr > mid) update(mid + 1, r, o << 1 | 1);
      maintain(l, r, o);
    }
  }
  void query(int l, int r, int o) {
    if (ql <= l && qr >= r) {
      ans = merge(ans, a[o]);
    } else {
      int mid = l + r >> 1;
      pushdown(l, r, o);
      if (ql <= mid) query(l, mid, o << 1);
      if (qr > mid) query(mid + 1, r, o << 1 | 1);
      maintain(l, r, o);
    }
  }
  node Query(int l, int r) {
    ans.clear();
    ql = l, qr = r;
    update(1, n, 1);
    query(1, n, 1);
    return ans;
  }
};
segtree tree;
int n, q;
void test() {
  node a, b, c;
  a.maxv = 1;
  a.ll = a.rl = 0;
  a.rr = a.lr = 1;
  a.same = 1;
  b.maxv = 1;
  b.ll = b.rl = 1;
  b.rr = b.lr = 0;
  b.same = 1;
  c = merge(a, b);
  c.print();
  c = merge(c, b);
  c.print();
}
int main(void) {
  scanf("%d%d", &n, &q);
  scanf("%s", s + 1);
  tree.init(n);
  for (; q--;) {
    int l, r;
    scanf("%d%d", &l, &r);
    auto v = tree.Query(l, r);
    printf("%d\n", v.maxv);
  }
  return 0;
}