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;
int read(int &x) { return scanf("%d", &x); }
int read(int &x, int &y) { return scanf("%d%d", &x, &y); }
int read(int &x, int &y, int &z) { return scanf("%d%d%d", &x, &y, &z); }
int read(long long &x) { return scanf("%lld", &x); }
int read(long long &x, long long &y) { return scanf("%lld%lld", &x, &y); }
int read(double &x) { return scanf("%lf", &x); }
char buff[2000010];
int read(string &s) {
  int r = scanf("%s", buff);
  s = buff;
  return r;
}
using namespace std;
template <class T, class U>
struct SegmentTree {
  struct Node {
    bool hasCarry = 0;
    int b = 0, e = 0;
    U carry = U();
    T val = T();
    Node() {}
    void join(const Node &l, const Node &r) {
      val = l.val + r.val;
      b = l.b;
      e = r.e;
    }
    void update(const U &u) {
      carry += u;
      u(val);
      hasCarry = 1;
    }
    void pushDown(Node &l, Node &r) {
      if (!hasCarry) return;
      l.update(carry.trim(0, r.e - r.b + 1));
      r.update(carry.trim(l.e - l.b + 1, 0));
      carry = U();
      hasCarry = 0;
    }
  };
  vector<Node> V;
  int N;
  SegmentTree(int N) : V(2 * N), N(N) {}
  template <class I>
  void create(const vector<I> &VEC, int b = 0, int e = -1) {
    if (e == -1) e = N - 1;
    int n = (((b) + (e)) | ((b) != (e)));
    if (b == e) {
      V[n].val = T(VEC[b]), V[n].b = b, V[n].e = e;
    } else {
      int m = (b + e) / 2;
      create(VEC, b, m);
      create(VEC, m + 1, e);
      V[n].join(V[(((b) + (m)) | ((b) != (m)))],
                V[(((m + 1) + (e)) | ((m + 1) != (e)))]);
    }
  }
  T query(int i, int j, int b = 0, int e = -1) {
    if (e == -1) e = N - 1;
    int n = (((b) + (e)) | ((b) != (e)));
    if (i <= b && e <= j) {
      return V[n].val;
    } else {
      int m = (b + e) / 2;
      V[n].pushDown(V[(((b) + (m)) | ((b) != (m)))],
                    V[(((m + 1) + (e)) | ((m + 1) != (e)))]);
      if (i > m) return query(i, j, m + 1, e);
      if (j <= m) return query(i, j, b, m);
      return query(i, j, b, m) + query(i, j, m + 1, e);
    }
  }
  int findOkPrefix(int i, const function<bool(T)> &isOk) {
    static int stk[50];
    int ssz = 0;
    stk[ssz++] = ((((0) + (N - 1)) | ((0) != (N - 1))));
    T acum;
    int sz = 0;
    while (ssz > 0) {
      int t = stk[--ssz];
      Node &n = V[t];
      int m = (n.b + n.e) / 2;
      if (n.e < i) continue;
      T newAcum = sz == 0 ? n.val : (acum + n.val);
      if (i <= n.b) {
        if (isOk(newAcum)) {
          sz += n.e - n.b + 1;
          acum = newAcum;
        } else {
          if (n.b == n.e) return sz;
          n.pushDown(V[(((n.b) + (m)) | ((n.b) != (m)))],
                     V[(((m + 1) + (n.e)) | ((m + 1) != (n.e)))]);
          stk[ssz++] = ((((m + 1) + (n.e)) | ((m + 1) != (n.e))));
          stk[ssz++] = ((((n.b) + (m)) | ((n.b) != (m))));
        }
      } else {
        if (n.b == n.e) continue;
        n.pushDown(V[(((n.b) + (m)) | ((n.b) != (m)))],
                   V[(((m + 1) + (n.e)) | ((m + 1) != (n.e)))]);
        stk[ssz++] = ((((m + 1) + (n.e)) | ((m + 1) != (n.e))));
        stk[ssz++] = ((((n.b) + (m)) | ((n.b) != (m))));
      }
    }
    return sz;
  }
  void update(int i, int j, const U &v, int b = 0, int e = -1) {
    if (e == -1) e = N - 1;
    int n = (((b) + (e)) | ((b) != (e)));
    if (i <= b && e <= j) {
      V[n].update(v.trim(max(b - i, 0), max(j - e, 0)));
    } else if (i > e || j < b)
      return;
    else {
      int m = (b + e) / 2;
      int l = (((b) + (m)) | ((b) != (m))),
          r = (((m + 1) + (e)) | ((m + 1) != (e)));
      V[n].pushDown(V[l], V[r]);
      update(i, j, v, b, m);
      update(i, j, v, m + 1, e);
      V[n].join(V[l], V[r]);
    }
  }
};
struct ConveyorSegment {
  string start, end;
  int cntL, cntR;
  int cntGroups;
  int best;
  ConveyorSegment(char c = '<') {
    cntGroups = best = cntL = cntR = 1;
    start = end = string(1, c);
  }
  ConveyorSegment operator+(const ConveyorSegment &a) const {
    ConveyorSegment r;
    bool sameGroupBetween = (end + a.start) != "<>";
    r.cntGroups = cntGroups + a.cntGroups - sameGroupBetween;
    r.cntL = cntL + (cntGroups == 1 && sameGroupBetween ? a.cntL : 0);
    r.cntR = a.cntR + (a.cntGroups == 1 && sameGroupBetween ? cntR : 0);
    r.best = max(max(best, a.best), sameGroupBetween ? cntR + a.cntL : 0);
    r.start = start;
    r.end = a.end;
    return r;
  }
};
struct DoubleConveryorSegment {
  ConveyorSegment current, other;
  DoubleConveryorSegment(char c = '<')
      : current(c), other(c == '<' ? '>' : '<') {}
  DoubleConveryorSegment operator+(const DoubleConveryorSegment &a) const {
    DoubleConveryorSegment r;
    r.current = current + a.current;
    r.other = other + a.other;
    return r;
  }
};
struct Flip {
  int x;
  Flip(int x = 0) : x(x) {}
  Flip trim(int l, int r) const { return *this; }
  void operator+=(const Flip &a) { x ^= a.x; }
  void operator()(DoubleConveryorSegment &a) const {
    if (x) swap(a.current, a.other);
  }
};
int main() {
  int TC = 1;
  while (TC-- > 0) {
    int N, M;
    read(N, M);
    string s;
    read(s);
    SegmentTree<DoubleConveryorSegment, Flip> ST(s.size());
    ST.create(vector<char>(s.begin(), s.end()));
    for (int i = 0; i < M; ++i) {
      int l, r;
      read(l, r);
      l--;
      r--;
      ST.update(l, r, Flip(+1));
      cout << ST.query(l, r).current.best << endl;
    }
  }
}