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 OP_NULL = 0;
const int OP_INV = 1;
struct Info {
  Info() {
    iROL[0] = iROL[1] = 0;
    eRLO[0] = eRLO[1] = 0;
    iL[0] = iL[1] = 0;
    iR[0] = iR[1] = 0;
    eR[0] = eR[1] = 0;
    eL[0] = eL[1] = 0;
    sol[0] = sol[1] = 0;
  }
  int iROL[2];
  int eRLO[2];
  int iL[2];
  int iR[2];
  int eR[2];
  int eL[2];
  int sol[2];
  int size;
};
class SegmentTreeLazy {
 public:
  SegmentTreeLazy(const vector<char> &initValues) {
    n = initValues.size();
    tree.resize(4 * n);
    lazy.assign(4 * n, OP_NULL);
    st_construct(0, 0, n - 1, initValues);
  }
  void updateRange(const int us, const int ue, const int op) {
    updateRange(0, 0, n - 1, us, ue, op);
  }
  Info getRange(const int qs, const int qe) {
    return getRange(0, n - 1, qs, qe, 0);
  }

 private:
  vector<Info> tree;
  vector<int> lazy;
  int n;
  inline int combineOp(const int opNew, const int opOld) {
    return ((opNew == opOld) ? OP_NULL : OP_INV);
  }
  inline Info getOpResult(const int si, const int ss, const int se,
                          const int op) {
    if (op == OP_INV) {
      swap(tree[si].iROL[0], tree[si].iROL[1]);
      swap(tree[si].eRLO[0], tree[si].eRLO[1]);
      swap(tree[si].iL[0], tree[si].iL[1]);
      swap(tree[si].iR[0], tree[si].iR[1]);
      swap(tree[si].eR[0], tree[si].eR[1]);
      swap(tree[si].eL[0], tree[si].eL[1]);
      swap(tree[si].sol[0], tree[si].sol[1]);
    }
    return tree[si];
  }
  inline Info combineResults(const Info &r1, const Info &r2) {
    Info newInfo;
    newInfo.size = r1.size + r2.size;
    for (int i = 0; i <= 1; i++) {
      newInfo.iL[i] = r1.iL[i];
      if (r1.iL[i] == r1.size) {
        newInfo.iL[i] += r2.iL[i];
      }
      newInfo.iR[i] = r1.iR[i];
      if (r1.iR[i] == r1.size) {
        newInfo.iR[i] += r2.iR[i];
      }
      newInfo.eR[i] = r2.eR[i];
      if (r2.eR[i] == r2.size) {
        newInfo.eR[i] += r1.eR[i];
      }
      newInfo.eL[i] = r2.eL[i];
      if (r2.eL[i] == r2.size) {
        newInfo.eL[i] += r1.eL[i];
      }
      newInfo.iROL[i] = r1.iROL[i];
      if (r1.iROL[i] == r1.size) {
        if (r1.iR[i] == r1.size) {
          newInfo.iROL[i] += r2.iROL[i];
        } else {
          newInfo.iROL[i] += r2.iL[i];
        }
      }
      newInfo.eRLO[i] = r2.eRLO[i];
      if (r2.eRLO[i] == r2.size) {
        if (r2.eL[i] == r2.size) {
          newInfo.eRLO[i] += r1.eRLO[i];
        } else {
          newInfo.eRLO[i] += r1.eR[i];
        }
      }
      newInfo.sol[i] =
          max(max(max(r1.sol[i], r2.sol[i]), r1.eRLO[i] + r2.iL[i]),
              r1.eR[i] + r2.iROL[i]);
    }
    return newInfo;
  }
  void st_construct(const int si, const int ss, const int se,
                    const vector<char> &initValues) {
    lazy[si] = OP_NULL;
    if (ss == se) {
      tree[si].size = 1;
      tree[si].iROL[0] = 1;
      tree[si].iROL[1] = 1;
      tree[si].eRLO[0] = 1;
      tree[si].eRLO[1] = 1;
      tree[si].iL[0] = 0;
      tree[si].iL[1] = 1;
      tree[si].iR[0] = 1;
      tree[si].iR[1] = 0;
      tree[si].eR[0] = 1;
      tree[si].eR[1] = 0;
      tree[si].eL[0] = 0;
      tree[si].eL[1] = 1;
      tree[si].sol[0] = 1;
      tree[si].sol[1] = 1;
      if (initValues[ss] == '<') {
        swap(tree[si].iROL[0], tree[si].iROL[1]);
        swap(tree[si].eRLO[0], tree[si].eRLO[1]);
        swap(tree[si].iL[0], tree[si].iL[1]);
        swap(tree[si].iR[0], tree[si].iR[1]);
        swap(tree[si].eR[0], tree[si].eR[1]);
        swap(tree[si].eL[0], tree[si].eL[1]);
        swap(tree[si].sol[0], tree[si].sol[1]);
      }
    } else {
      const int mid = (ss + se) / 2;
      st_construct(si * 2 + 1, ss, mid, initValues);
      st_construct(si * 2 + 2, mid + 1, se, initValues);
      tree[si] = combineResults(tree[si * 2 + 1], tree[si * 2 + 2]);
    }
  }
  inline void applyLazyOp(const int si, const int ss, const int se) {
    tree[si] = getOpResult(si, ss, se, lazy[si]);
    if (ss != se) {
      lazy[si * 2 + 1] = combineOp(lazy[si], lazy[si * 2 + 1]);
      lazy[si * 2 + 2] = combineOp(lazy[si], lazy[si * 2 + 2]);
    }
    lazy[si] = OP_NULL;
  }
  void updateRange(const int si, const int ss, const int se, const int us,
                   const int ue, const int op) {
    applyLazyOp(si, ss, se);
    if (ss > ue || se < us) return;
    if (ss >= us && se <= ue) {
      tree[si] = getOpResult(si, ss, se, op);
      if (ss != se) {
        lazy[si * 2 + 1] = combineOp(op, lazy[si * 2 + 1]);
        lazy[si * 2 + 2] = combineOp(op, lazy[si * 2 + 2]);
      }
      return;
    }
    const int mid = (ss + se) / 2;
    updateRange(si * 2 + 1, ss, mid, us, ue, op);
    updateRange(si * 2 + 2, mid + 1, se, us, ue, op);
    tree[si] = combineResults(tree[si * 2 + 1], tree[si * 2 + 2]);
  }
  Info getRange(const int ss, const int se, const int qs, const int qe,
                const int si) {
    applyLazyOp(si, ss, se);
    if (ss > qe || se < qs) {
      return Info();
    }
    if (ss >= qs && se <= qe) return tree[si];
    int mid = (ss + se) / 2;
    return combineResults(getRange(ss, mid, qs, qe, 2 * si + 1),
                          getRange(mid + 1, se, qs, qe, 2 * si + 2));
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<char> in;
  for (int i = 0; i < s.size(); i++) {
    in.push_back(s[i]);
  }
  SegmentTreeLazy stl(in);
  for (int i = 0; i < q; i++) {
    int from, to;
    cin >> from >> to;
    stl.updateRange(from - 1, to - 1, OP_INV);
    Info info = stl.getRange(from - 1, to - 1);
    cout << info.sol[0] << "\n";
  }
  return 0;
}