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>
int n, q;
struct Data {
  int max;
  std::vector<std::pair<int, int>> part;
  Data() : max(0) {}
  friend Data operator+(const Data &lhs, const Data &rhs) {
    Data res;
    res.max = std::max(lhs.max, rhs.max);
    res.part = lhs.part;
    for (auto [t, len] : rhs.part) {
      if (res.part.back().first == t) {
        res.part.back().second += len;
      } else {
        res.part.emplace_back(t, len);
      }
    }
    for (int i = 0; i < int(res.part.size()); ++i) {
      res.max = std::max(res.max, res.part[i].second);
      if (i + 1 < int(res.part.size()) && res.part[i].first == 0)
        res.max =
            std::max(res.max, res.part[i].second + res.part[i + 1].second);
    }
    for (int i = 1; i + 2 < int(res.part.size()); ++i) {
      if (res.part[i].first == 0) {
        res.part.erase(res.part.begin() + i, res.part.begin() + i + 2);
        --i;
      }
    }
    return res;
  }
};
Data unitl, unitr;
struct SegmentTree {
  int n;
  std::vector<int> tag;
  std::vector<Data> t, neg;
  SegmentTree(const std::string &s)
      : n(s.length()), tag(4 * n), t(4 * n), neg(4 * n) {
    build(1, 0, n, s);
  }
  void pull(int p) {
    t[p] = t[2 * p] + t[2 * p + 1];
    neg[p] = neg[2 * p] + neg[2 * p + 1];
  }
  void build(int p, int l, int r, const std::string &s) {
    if (r - l == 1) {
      t[p] = unitl;
      neg[p] = unitr;
      if (s[l] == '>') std::swap(t[p], neg[p]);
    } else {
      int m = (l + r) / 2;
      build(2 * p, l, m, s);
      build(2 * p + 1, m, r, s);
      pull(p);
    }
  }
  void flip(int p) {
    tag[p] ^= 1;
    std::swap(t[p], neg[p]);
  }
  void push(int p) {
    if (tag[p]) {
      flip(2 * p);
      flip(2 * p + 1);
      tag[p] = 0;
    }
  }
  Data query(int p, int l, int r, int x, int y) {
    if (l >= x && r <= y) {
      flip(p);
      return t[p];
    } else {
      int m = (l + r) / 2;
      push(p);
      Data res;
      if (y <= m) {
        res = query(2 * p, l, m, x, y);
      } else if (x >= m) {
        res = query(2 * p + 1, m, r, x, y);
      } else {
        res = query(2 * p, l, m, x, y) + query(2 * p + 1, m, r, x, y);
      }
      pull(p);
      return res;
    }
  }
  int query(int l, int r) { return query(1, 0, n, l, r).max; }
};
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  unitl.max = unitr.max = 1;
  unitl.part = {std::make_pair(1, 1)};
  unitr.part = {std::make_pair(0, 1)};
  std::cin >> n >> q;
  std::string s;
  std::cin >> s;
  SegmentTree t(s);
  while (q--) {
    int l, r;
    std::cin >> l >> r;
    --l;
    std::cout << t.query(l, r) << "\n";
  }
  return 0;
}