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 N = 5e5 + 7;
struct Node {
  int ans1, ans2, len;
  vector<pair<int, char> > l, r;
  Node() {
    l = r = {};
    ans1 = ans2 = len = 0;
  }
};
void rel(int &a, int b) { a = max(a, b); }
Node merge(Node &l, Node &r) {
  if (l.ans1 == 0) return r;
  if (r.ans1 == 0) return l;
  Node ans;
  ans.len = l.len + r.len;
  ans.l = l.l;
  if (ans.l.size() == 1) {
    int ptr = 0;
    if (r.l[0].second == ans.l.back().second) {
      ans.l.back().first += r.l[0].first;
      ++ptr;
    }
    if (ptr < r.l.size()) {
      ans.l.push_back(r.l[ptr]);
    }
  } else if (l.len == ans.l[0].first + ans.l[1].first &&
             ans.l[1].second == r.l[0].second) {
    ans.l[1].first += r.l[0].first;
  }
  ans.r = r.r;
  if (ans.r.size() == 1) {
    int ptr = 0;
    if (l.r[0].second == ans.r.back().second) {
      ans.r.back().first += l.r[0].first;
      ++ptr;
    }
    if (ptr < l.r.size()) {
      ans.r.push_back(l.r[ptr]);
    }
  } else if (r.len == ans.r[0].first + ans.r[1].first &&
             ans.r[1].second == l.r[0].second) {
    ans.r[1].first += l.r[0].first;
  }
  ans.ans1 = ans.ans2 = 0;
  for (auto e : ans.l) {
    ans.ans1 = max(ans.ans1, e.first);
    ans.ans2 = max(ans.ans2, e.first);
  }
  for (auto e : ans.r) {
    ans.ans1 = max(ans.ans1, e.first);
    ans.ans2 = max(ans.ans2, e.first);
  }
  auto relax = [&](pair<int, char> l, pair<int, char> r) {
    if (l.second == '>') {
      rel(ans.ans1, l.first + r.first);
    } else {
      rel(ans.ans2, l.first + r.first);
    }
  };
  if (ans.l.size() == 2) {
    relax(ans.l[0], ans.l[1]);
  }
  if (ans.r.size() == 2) {
    relax(ans.r[1], ans.r[0]);
  }
  if (l.r[0].second != r.l[0].second) {
    relax(l.r[0], r.l[0]);
  } else {
    pair<int, char> mid = make_pair(l.r[0].first + r.l[0].first, l.r[0].second);
    if (l.r.size() == 2) {
      relax(l.r[1], mid);
    }
    if (r.l.size() == 2) {
      relax(mid, r.l[1]);
    }
  }
  rel(ans.ans1, l.ans1);
  rel(ans.ans2, l.ans2);
  rel(ans.ans1, r.ans1);
  rel(ans.ans2, r.ans2);
  return ans;
}
char inv(char c) {
  if (c == '<')
    return '>';
  else
    return '<';
}
int n, q;
string second;
Node tree[N << 2];
bool prop[N << 2];
void build(int v, int tl, int tr) {
  if (tl == tr) {
    tree[v].l = tree[v].r = {make_pair(1, second[tl])};
    tree[v].ans1 = tree[v].ans2 = tree[v].len = 1;
    return;
  }
  int tm = (tl + tr) >> 1;
  build(v * 2 + 1, tl, tm);
  build(v * 2 + 2, tm + 1, tr);
  tree[v] = merge(tree[v * 2 + 1], tree[v * 2 + 2]);
}
void gap(int v) {
  for (auto &e : tree[v].l) {
    e.second = inv(e.second);
  }
  for (auto &e : tree[v].r) {
    e.second = inv(e.second);
  }
  swap(tree[v].ans1, tree[v].ans2);
  prop[v] ^= 1;
}
void push(int v) {
  if (prop[v]) {
    gap(v * 2 + 1);
    gap(v * 2 + 2);
    prop[v] = 0;
  }
}
Node upd(int v, int tl, int tr, int l, int r) {
  if (tr < l || r < tl) return Node();
  if (l <= tl && tr <= r) {
    gap(v);
    return tree[v];
  }
  int tm = (tl + tr) >> 1;
  push(v);
  auto ansl = upd(v * 2 + 1, tl, tm, l, r);
  auto ansr = upd(v * 2 + 2, tm + 1, tr, l, r);
  tree[v] = merge(tree[v * 2 + 1], tree[v * 2 + 2]);
  return merge(ansl, ansr);
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> q;
  cin >> second;
  build(0, 0, n - 1);
  for (int i = 0; i < q; ++i) {
    int l, r;
    cin >> l >> r;
    --l;
    --r;
    cout << upd(0, 0, n - 1, l, r).ans1 << '\n';
  }
}