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;
struct node {
  int prefix_plus, suffix_minus, prefix_plus_minus, suffix_minus_plus,
      best_plus_minus;
  int prefix_minus, suffix_plus, prefix_minus_plus, suffix_plus_minus,
      best_minus_plus;
  int length, is_lazy;
  node() {
    length = 0;
    is_lazy = false;
    prefix_plus = prefix_minus = suffix_plus = suffix_minus = 0;
    prefix_plus_minus = prefix_minus_plus = suffix_minus_plus =
        suffix_plus_minus = 0;
    best_minus_plus = best_plus_minus = 0;
  };
  node(char ch) {
    switch (ch) {
      case '<': {
        prefix_plus = 1;
        suffix_plus = 1;
        prefix_minus = 0;
        suffix_minus = 0;
        break;
      }
      case '>': {
        prefix_minus = 1;
        suffix_minus = 1;
        prefix_plus = 0;
        suffix_plus = 0;
        break;
      }
    }
    is_lazy = false;
    length = 1;
    prefix_plus_minus = prefix_minus_plus = suffix_minus_plus =
        suffix_plus_minus = 0;
    best_minus_plus = best_plus_minus = 0;
  }
};
const int MAX_N = 5e5 + 5;
node tree[3 * MAX_N];
string S;
void print(node n) {
  cout << "Length = " << n.length << "\n";
  cout << "PREFIX :\n";
  cout << "< = " << n.prefix_plus << " > = " << n.prefix_minus
       << " <> = " << n.prefix_plus_minus << " >< " << n.prefix_minus_plus
       << "\n";
  cout << "suffix :\n";
  cout << "< = " << n.suffix_plus << " > = " << n.suffix_minus
       << " <> = " << n.suffix_plus_minus << " >< " << n.suffix_minus_plus
       << "\n";
  cout << "BEST\n";
  cout << " >< " << n.best_minus_plus << " <> " << n.best_plus_minus << "\n";
}
void flip_flag(int &n) { n = !(n); }
void flip(int n) {
  swap(tree[n].prefix_plus, tree[n].prefix_minus);
  swap(tree[n].suffix_minus, tree[n].suffix_plus);
  swap(tree[n].prefix_plus_minus, tree[n].prefix_minus_plus);
  swap(tree[n].suffix_plus_minus, tree[n].suffix_minus_plus);
  swap(tree[n].best_plus_minus, tree[n].best_minus_plus);
}
void merge(node &L, node &R, node &answer) {
  if (L.length == 0) {
    answer = R;
    return;
  }
  if (R.length == 0) {
    answer = L;
    return;
  }
  answer.length = L.length + R.length;
  answer.prefix_plus =
      L.prefix_plus + (L.prefix_plus == L.length ? R.prefix_plus : 0);
  answer.prefix_minus =
      L.prefix_minus + (L.prefix_minus == L.length ? R.prefix_minus : 0);
  answer.suffix_plus =
      R.suffix_plus + (R.suffix_plus == R.length ? L.suffix_plus : 0);
  answer.suffix_minus =
      R.suffix_minus + (R.suffix_minus == R.length ? L.suffix_minus : 0);
  answer.prefix_plus_minus = L.prefix_plus_minus;
  if (L.prefix_plus_minus == L.length) {
    answer.prefix_plus_minus += R.prefix_minus;
  }
  if (L.prefix_plus == L.length) {
    if (R.prefix_minus != 0) {
      answer.prefix_plus_minus =
          max(answer.prefix_plus_minus, L.prefix_plus + R.prefix_minus);
    }
    if (R.prefix_plus_minus != 0) {
      answer.prefix_plus_minus =
          max(answer.prefix_plus_minus, L.prefix_plus + R.prefix_plus_minus);
    }
  }
  answer.prefix_minus_plus = L.prefix_minus_plus;
  if (L.prefix_minus_plus == L.length) {
    answer.prefix_minus_plus += R.prefix_plus;
  }
  if (L.prefix_minus == L.length) {
    if (R.prefix_plus != 0) {
      answer.prefix_minus_plus =
          max(answer.prefix_minus_plus, L.prefix_minus + R.prefix_plus);
    }
    if (R.prefix_minus_plus != 0) {
      answer.prefix_minus_plus =
          max(answer.prefix_minus_plus, L.prefix_minus + R.prefix_minus_plus);
    }
  }
  answer.suffix_plus_minus = R.suffix_plus_minus;
  if (R.suffix_plus_minus == R.length) {
    answer.suffix_plus_minus += L.suffix_plus;
  }
  if (R.suffix_minus == R.length) {
    if (L.suffix_plus != 0) {
      answer.suffix_plus_minus =
          max(answer.suffix_plus_minus, L.suffix_plus + R.suffix_minus);
    }
    if (L.suffix_plus_minus != 0) {
      answer.suffix_plus_minus =
          max(answer.suffix_plus_minus, L.suffix_plus_minus + R.suffix_minus);
    }
  }
  answer.suffix_minus_plus = R.suffix_minus_plus;
  if (R.suffix_minus_plus == R.length) {
    answer.suffix_minus_plus += L.suffix_minus;
  }
  if (R.suffix_plus == R.length) {
    if (L.suffix_minus != 0) {
      answer.suffix_minus_plus =
          max(answer.suffix_minus_plus, L.suffix_minus + R.suffix_plus);
    }
    if (L.suffix_minus_plus != 0) {
      answer.suffix_minus_plus =
          max(answer.suffix_minus_plus, L.suffix_minus_plus + R.suffix_plus);
    }
  }
  answer.best_plus_minus = max(L.best_plus_minus, R.best_plus_minus);
  answer.best_plus_minus = max(answer.best_plus_minus,
                               max(L.prefix_plus_minus, R.suffix_plus_minus));
  if (L.suffix_plus > 0 && R.prefix_minus > 0) {
    answer.best_plus_minus =
        max(answer.best_plus_minus, L.suffix_plus + R.prefix_minus);
  }
  if (L.suffix_plus_minus > 0) {
    answer.best_plus_minus =
        max(answer.best_plus_minus, L.suffix_plus_minus + R.prefix_minus);
  }
  if (R.prefix_plus_minus > 0) {
    answer.best_plus_minus =
        max(answer.best_plus_minus, L.suffix_plus + R.prefix_plus_minus);
  }
  answer.best_minus_plus = max(L.best_minus_plus, R.best_minus_plus);
  answer.best_minus_plus = max(answer.best_minus_plus,
                               max(L.prefix_minus_plus, R.suffix_minus_plus));
  if (L.suffix_minus > 0 && R.prefix_plus > 0) {
    answer.best_minus_plus =
        max(answer.best_minus_plus, L.suffix_minus + R.prefix_plus);
  }
  if (L.suffix_minus_plus > 0) {
    answer.best_minus_plus =
        max(answer.best_minus_plus, L.suffix_minus_plus + R.prefix_plus);
  }
  if (R.prefix_minus_plus > 0) {
    answer.best_minus_plus =
        max(answer.best_minus_plus, L.suffix_minus + R.prefix_minus_plus);
  }
}
void propagate(int n, int left, int right) {
  if (tree[n].is_lazy == false) {
    return;
  }
  flip(n);
  if (left != right) {
    flip_flag(tree[(2 * n)].is_lazy);
    flip_flag(tree[(2 * n + 1)].is_lazy);
  }
  tree[n].is_lazy = false;
}
void build(int n, int left, int right) {
  if (left == right) {
    tree[n] = node(S[left - 1]);
    return;
  }
  int mid = (left + right) / 2;
  build((2 * n), left, mid);
  build((2 * n + 1), mid + 1, right);
  merge(tree[(2 * n)], tree[(2 * n + 1)], tree[n]);
}
void update(int n, int left, int right, int query_left, int query_right) {
  propagate(n, left, right);
  if (query_right < left || right < query_left) {
    return;
  }
  if (query_left <= left && right <= query_right) {
    flip_flag(tree[n].is_lazy);
    propagate(n, left, right);
    return;
  }
  int mid = (left + right) / 2;
  update((2 * n), left, mid, query_left, query_right);
  update((2 * n + 1), mid + 1, right, query_left, query_right);
  merge(tree[(2 * n)], tree[(2 * n + 1)], tree[n]);
}
node get_answer(int n, int left, int right, int query_left, int query_right) {
  propagate(n, left, right);
  if (query_right < left || right < query_left) {
    return node();
  }
  if (query_left <= left && right <= query_right) {
    return tree[n];
  }
  int mid = (left + right) / 2;
  node L = get_answer((2 * n), left, mid, query_left, query_right);
  node R = get_answer((2 * n + 1), mid + 1, right, query_left, query_right);
  node answer;
  merge(L, R, answer);
  return answer;
}
int main() {
  int length, no_of_queries;
  cin >> length >> no_of_queries;
  cin >> S;
  build(1, 1, length);
  for (int i = 1; i <= no_of_queries; i++) {
    int left, right;
    cin >> left >> right;
    update(1, 1, length, left, right);
    node answer = get_answer(1, 1, length, left, right);
    int best_answer = max(answer.prefix_plus,
                          max(answer.best_minus_plus, answer.suffix_minus));
    cout << best_answer << "\n";
  }
  return 0;
}