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;
mt19937_64 mt(time(0));
const int MAXN = 5e5 + 10;
struct Item {
  bool head;
  int len = 0;
  int8_t type[2] = {};
  int in = 0;
  int cnt[2] = {};
  Item() = default;
  Item(int h) {
    head = h;
    len = 1;
    type[1 - h] = 1;
    cnt[1 - h] = 1;
  }
};
string s;
Item tree[MAXN << 2][2];
int idx[MAXN << 2], info[MAXN << 2];
Item merge(const Item& x, const Item& y) {
  if (x.len == 0) return y;
  if (y.len == 0) return x;
  Item ret;
  ret.head = x.head;
  ret.len = x.len + y.len;
  if ((x.head + x.len - 1) % 2 == y.head) ret.len--;
  ret.in = max(x.in, y.in);
  if (x.type[0] == 0 && x.type[1] == 1) {
    if (y.type[0] == 0 && y.type[1] == 1) {
      ret.type[1] = 1;
      ret.cnt[1] = x.cnt[1] + y.cnt[1];
    } else if (y.type[1] == 0) {
      ret.type[0] = 2;
      ret.cnt[0] = x.cnt[1] + y.cnt[0];
    } else {
      ret.type[0] = 2;
      ret.type[1] = y.type[1];
      ret.cnt[0] = x.cnt[1] + y.cnt[0];
      ret.cnt[1] = y.cnt[1];
    }
    return ret;
  }
  if (x.type[0] == 1 && x.type[1] == 0) {
    if (y.type[0] == 0 || y.type[0] == 1) {
      ret.type[0] = 1;
      ret.type[1] = y.type[1];
      ret.cnt[0] = x.cnt[0] + y.cnt[0];
      ret.cnt[1] = y.cnt[1];
    } else if (y.type[1] == 0) {
      ret.type[0] = 1;
      ret.type[1] = 2;
      ret.cnt[0] = x.cnt[0];
      ret.cnt[1] = y.cnt[0];
    } else {
      ret.type[0] = 1;
      ret.type[1] = y.type[1];
      ret.in = max(ret.in, y.cnt[0]);
      ret.cnt[0] = x.cnt[0];
      ret.cnt[1] = y.cnt[1];
    }
    return ret;
  }
  if (x.type[0] == 2 && x.type[1] == 0 && y.type[0] == 2 && y.type[1] == 0) {
    ret.type[0] = 2;
    ret.type[1] = 2;
    ret.cnt[0] = x.cnt[0];
    ret.cnt[1] = y.cnt[0];
    return ret;
  }
  if (x.type[0] == 2 && x.type[1] == 0 && y.type[0] == 1) {
    ret.type[0] = 2;
    ret.type[1] = y.type[1];
    ret.cnt[0] = x.cnt[0] + y.cnt[0];
    ret.cnt[1] = y.cnt[1];
    return ret;
  }
  if (y.type[0] == 0 && x.type[1] == 1) {
    ret.type[0] = x.type[0];
    ret.type[1] = 1;
    ret.cnt[0] = x.cnt[0];
    ret.cnt[1] = x.cnt[1] + y.cnt[1];
    return ret;
  }
  if (y.type[0] == 1 && y.type[1] == 0) {
    ret.type[0] = x.type[0];
    ret.type[1] = 2;
    ret.cnt[0] = x.cnt[0];
    ret.cnt[1] = x.cnt[1] + y.cnt[0];
    return ret;
  }
  if (y.type[0] == 2 && y.type[1] == 0) {
    if (x.type[1] == 1) {
      ret.type[0] = x.type[0];
      ret.type[1] = 2;
      ret.cnt[0] = x.cnt[0];
      ret.cnt[1] = x.cnt[1] + y.cnt[0];
    } else {
      ret.type[0] = x.type[0];
      ret.type[1] = 2;
      ret.in = max(ret.in, x.cnt[1]);
      ret.cnt[0] = x.cnt[0];
      ret.cnt[1] = y.cnt[0];
    }
    return ret;
  }
  ret.type[0] = x.type[0];
  ret.type[1] = y.type[1];
  ret.cnt[0] = x.cnt[0];
  ret.cnt[1] = y.cnt[1];
  if (x.type[1] == 2 && y.type[0] == 2) {
    ret.in = max(ret.in, x.cnt[1]);
    ret.in = max(ret.in, y.cnt[0]);
  } else
    ret.in = max(ret.in, x.cnt[1] + y.cnt[0]);
  return ret;
}
void build(int node, int left, int right) {
  if (left == right) {
    if (s[left - 1] == '>') {
      tree[node][0] = Item(0);
      tree[node][1] = Item(1);
    } else {
      tree[node][0] = Item(1);
      tree[node][1] = Item(0);
    }
    return;
  }
  int mid = ((left + right) >> 1);
  build((node << 1), left, mid);
  build(((node << 1) | 1), mid + 1, right);
  tree[node][0] = merge(tree[(node << 1)][0], tree[((node << 1) | 1)][0]);
  tree[node][1] = merge(tree[(node << 1)][1], tree[((node << 1) | 1)][1]);
}
void push_down(int node, int left, int right) {
  if (left == right || info[node] == 0) return;
  idx[(node << 1)] ^= 1;
  idx[((node << 1) | 1)] ^= 1;
  info[(node << 1)] ^= 1;
  info[((node << 1) | 1)] ^= 1;
  info[node] = 0;
}
void update(int node, int left, int right, int i, int j) {
  if (right < i || j < left) return;
  if (i <= left && right <= j) {
    info[node] ^= 1;
    idx[node] ^= 1;
    return;
  }
  push_down(node, left, right);
  int mid = ((left + right) >> 1);
  update((node << 1), left, mid, i, j);
  update(((node << 1) | 1), mid + 1, right, i, j);
  tree[node][idx[node]] =
      merge(tree[(node << 1)][idx[(node << 1)]],
            tree[((node << 1) | 1)][idx[((node << 1) | 1)]]);
  tree[node][idx[node] ^ 1] =
      merge(tree[(node << 1)][idx[(node << 1)] ^ 1],
            tree[((node << 1) | 1)][idx[((node << 1) | 1)] ^ 1]);
}
Item query(int node, int left, int right, int i, int j) {
  if (right < i || j < left) return Item();
  if (i <= left && right <= j) {
    return tree[node][idx[node]];
  }
  push_down(node, left, right);
  int mid = ((left + right) >> 1);
  Item a = query((node << 1), left, mid, i, j);
  Item b = query(((node << 1) | 1), mid + 1, right, i, j);
  return merge(a, b);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(10);
  cout << fixed;
  int n, q;
  cin >> n >> q;
  cin >> s;
  build(1, 1, n);
  while (q--) {
    int a, b;
    cin >> a >> b;
    update(1, 1, n, a, b);
    Item tmp = query(1, 1, n, a, b);
    int ret = max(tmp.cnt[0], tmp.cnt[1]);
    ret = max(ret, tmp.in);
    cout << ret << '\n';
  }
  return 0;
}