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;
bool lazy[2000001];
string s;
struct Seg {
  bool single[2];
  pair<int, int> pre[2], suf[2];
  int ctr[2];
} seg[2000001];
void mergeC(Seg &res, Seg l, Seg r) {
  for (int k = 0; k < 2; k++) {
    if (l.single[k] && r.single[k]) {
      res.ctr[k] = 0;
      if (r.pre[k].first == 0) {
        res.single[k] = true;
        res.pre[k] = res.suf[k] =
            make_pair(l.pre[k].first, l.pre[k].second + r.pre[k].second);
        continue;
      }
      if (l.pre[k].second == 0) {
        res.single[k] = true;
        res.pre[k] = res.suf[k] =
            make_pair(l.pre[k].first + r.pre[k].first, r.pre[k].second);
        continue;
      }
      res.single[k] = false;
      res.pre[k] = l.pre[k];
      res.suf[k] = r.suf[k];
      res.ctr[k] = 0;
      continue;
    }
    res.single[k] = false;
    if (l.single[k]) {
      res.ctr[k] = r.ctr[k];
      res.suf[k] = r.suf[k];
      if (r.pre[k].first == 0) {
        res.pre[k] =
            make_pair(l.pre[k].first, l.pre[k].second + r.pre[k].second);
        continue;
      }
      if (l.pre[k].second == 0) {
        res.pre[k] =
            make_pair(l.pre[k].first + r.pre[k].first, r.pre[k].second);
        continue;
      }
      res.pre[k] = l.pre[k];
      res.ctr[k] = max(res.ctr[k], r.pre[k].first + r.pre[k].second);
      continue;
    }
    if (r.single[k]) {
      res.ctr[k] = l.ctr[k];
      res.pre[k] = l.pre[k];
      if (l.suf[k].second == 0) {
        res.suf[k] =
            make_pair(l.suf[k].first + r.pre[k].first, r.pre[k].second);
        continue;
      }
      if (r.pre[k].first == 0) {
        res.suf[k] =
            make_pair(l.suf[k].first, l.suf[k].second + r.pre[k].second);
        continue;
      }
      res.suf[k] = r.suf[k];
      res.ctr[k] = max(res.ctr[k], l.suf[k].first + l.suf[k].second);
      continue;
    }
    res.pre[k] = l.pre[k];
    res.suf[k] = r.suf[k];
    int &nctr = res.ctr[k];
    nctr = max(l.ctr[k], r.ctr[k]);
    if (l.suf[k].second == 0) {
      nctr = max(nctr, l.suf[k].first + r.pre[k].first + r.pre[k].second);
      continue;
    }
    if (r.pre[k].first == 0) {
      nctr = max(nctr, l.suf[k].first + l.suf[k].second + r.pre[k].second);
      continue;
    }
    nctr = max(nctr, l.suf[k].first + l.suf[k].second);
    nctr = max(nctr, r.pre[k].first + r.pre[k].second);
    continue;
  }
}
void build(int n, int l, int r) {
  Seg &res = seg[n];
  if (l == r) {
    res.single[0] = res.single[1] = true;
    if (s[l - 1] == '<') {
      res.pre[0] = res.suf[0] = make_pair(0, 1);
      res.pre[1] = res.suf[1] = make_pair(1, 0);
    } else {
      res.pre[0] = res.suf[0] = make_pair(1, 0);
      res.pre[1] = res.suf[1] = make_pair(0, 1);
    }
    return;
  }
  int m = (l + r) / 2;
  build(n * 2, l, m);
  build(n * 2 + 1, m + 1, r);
  mergeC(res, seg[n * 2], seg[n * 2 + 1]);
}
void push_lazy(int n, int l, int r) {
  if (!lazy[n]) return;
  lazy[n] = false;
  swap(seg[n].pre[0], seg[n].pre[1]);
  swap(seg[n].suf[0], seg[n].suf[1]);
  swap(seg[n].ctr[0], seg[n].ctr[1]);
  swap(seg[n].single[0], seg[n].single[1]);
  if (l == r) return;
  lazy[n * 2] = !lazy[n * 2];
  lazy[n * 2 + 1] = !lazy[n * 2 + 1];
}
void update(int n, int l, int r, int lx, int rx) {
  Seg &res = seg[n];
  push_lazy(n, l, r);
  if (lx > r || rx < l) return;
  if (lx <= l && r <= rx) {
    lazy[n] = true;
    push_lazy(n, l, r);
    return;
  }
  int m = (l + r) / 2;
  update(n * 2, l, m, lx, rx);
  update(n * 2 + 1, m + 1, r, lx, rx);
  mergeC(res, seg[n * 2], seg[n * 2 + 1]);
}
Seg query(int n, int l, int r, int lx, int rx) {
  if (lx <= l && r <= rx) {
    return seg[n];
  }
  int m = (l + r) / 2;
  if (lx > m) {
    return query(n * 2 + 1, m + 1, r, lx, rx);
  }
  if (rx <= m) {
    return query(n * 2, l, m, lx, rx);
  }
  Seg res;
  mergeC(res, query(n * 2, l, m, lx, rx), query(n * 2 + 1, m + 1, r, lx, rx));
  return res;
}
int main() {
  int n, q;
  cin >> n >> q;
  cin >> s;
  build(1, 1, n);
  for (int qq = 1; qq <= q; qq++) {
    int l, r;
    cin >> l >> r;
    update(1, 1, n, l, r);
    Seg res = query(1, 1, n, l, r);
    cout << max(res.ctr[0], max(res.pre[0].first + res.pre[0].second,
                                res.suf[0].first + res.suf[0].second))
         << '\n';
  }
}