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;
template <class T>
void Output(const T& v, bool print_new_line = true) {
  bool first = true;
  for (auto element : v) {
    if (!first)
      cout << " ";
    else
      first = false;
    cout << element;
  }
  if (print_new_line) cout << endl;
}
template <class T>
void Input(vector<T>& v, int n) {
  v.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
}
template <class T>
vector<int> Query(const T& c, int answer_counts) {
  cout << "? " << c.size();
  for (auto it = c.begin(); it != c.end(); ++it) {
    cout << " " << (*it);
  }
  cout << endl;
  cout.flush();
  vector<int> s(answer_counts);
  for (int i = 0; i < answer_counts; ++i) {
    cin >> s[i];
  }
  return s;
}
vector<pair<int, int>> left_two_segments;
vector<pair<int, int>> right_two_segments;
vector<int> max_sink_distances;
vector<int> max_source_distances;
vector<int> swaps;
int buffer[4];
int k = -1;
pair<int, int> mergeSegments(const pair<int, int>& l, const pair<int, int>& r,
                             bool left) {
  k = 0;
  for (int s : {l.first, l.second, r.first, r.second}) {
    if (s == 0) continue;
    if (k > 0 && ((s > 0) == (buffer[k - 1] > 0))) {
      buffer[k - 1] += s;
      continue;
    }
    buffer[k++] = s;
  }
  if (left) {
    return make_pair(k > 0 ? buffer[0] : 0, k > 1 ? buffer[1] : 0);
  } else {
    return make_pair(k > 1 ? buffer[k - 2] : 0, k > 0 ? buffer[k - 1] : 0);
  }
}
void rebuild(int node, int left, int right) {
  int center = (right + left) / 2;
  int left_child = node * 2 + 1;
  int right_child = node * 2 + 2;
  left_two_segments[node] =
      (center - left == abs(left_two_segments[left_child].first) +
                            abs(left_two_segments[left_child].second))
          ? mergeSegments(left_two_segments[left_child],
                          left_two_segments[right_child], true)
          : left_two_segments[left_child];
  right_two_segments[node] =
      (right - center == abs(right_two_segments[right_child].first) +
                             abs(right_two_segments[right_child].second))
          ? mergeSegments(right_two_segments[left_child],
                          right_two_segments[right_child], false)
          : right_two_segments[right_child];
  mergeSegments(right_two_segments[left_child], left_two_segments[right_child],
                true);
  max_sink_distances[node] =
      max(max_sink_distances[left_child], max_sink_distances[right_child]);
  max_source_distances[node] =
      max(max_source_distances[left_child], max_source_distances[right_child]);
  int last_sink = -1;
  int last_source = -1;
  int t = 0;
  for (int i = 0; i <= k; ++i) {
    if ((i < k && buffer[i] > 0) || (i > 0 && buffer[i - 1] < 0)) {
      if (last_source >= 0) {
        if (t - last_source > max_source_distances[node]) {
          max_source_distances[node] = t - last_source;
        }
      }
      last_source = t;
    } else {
      if (last_sink >= 0) {
        if (t - last_sink > max_sink_distances[node]) {
          max_sink_distances[node] = t - last_sink;
        }
      }
      last_sink = t;
    }
    t += abs(buffer[i]);
  }
}
void doSwap(int node) {
  left_two_segments[node].first = -left_two_segments[node].first;
  left_two_segments[node].second = -left_two_segments[node].second;
  right_two_segments[node].first = -right_two_segments[node].first;
  right_two_segments[node].second = -right_two_segments[node].second;
  swap(max_sink_distances[node], max_source_distances[node]);
}
void build(int node, int left, int right, const string& str) {
  if (right - left == 1) {
    left_two_segments[node] = make_pair((str[left] == '>' ? 1 : -1), 0);
    right_two_segments[node] = make_pair(0, (str[left] == '>' ? 1 : -1));
    max_sink_distances[node] = 0;
    max_source_distances[node] = 0;
    return;
  }
  int center = (right + left) / 2;
  int left_child = node * 2 + 1;
  int right_child = node * 2 + 2;
  build(left_child, left, center, str);
  build(right_child, center, right, str);
  rebuild(node, left, right);
}
int sign(int x) { return (x > 0) - (x < 0); }
int queryAndReverse(int start, int end, int node, int left, int right) {
  if (right <= start || end <= left) {
    return 0;
  }
  if (start <= left && right <= end) {
    ++swaps[node];
    doSwap(node);
    return std::max(max_source_distances[node],
                    std::max(abs(left_two_segments[node].first),
                             abs(right_two_segments[node].second)));
  }
  int center = (right + left) / 2;
  int left_child = node * 2 + 1;
  int right_child = node * 2 + 2;
  if (swaps[node] % 2 == 1) {
    doSwap(left_child);
    doSwap(right_child);
  }
  swaps[left_child] += swaps[node];
  swaps[right_child] += swaps[node];
  swaps[node] = 0;
  int r = std::max(queryAndReverse(start, end, left_child, left, center),
                   queryAndReverse(start, end, right_child, center, right));
  rebuild(node, left, right);
  if (start < center && end > center) {
    auto left = right_two_segments[left_child];
    auto right = left_two_segments[right_child];
    if (abs(left.second) > center - start) {
      left.second = sign(left.second) * (center - start);
      left.first = 0;
    } else if (abs(left.second) + abs(left.first) > center - start) {
      left.first = sign(left.first) * (center - start - abs(left.second));
    }
    if (abs(right.first) > end - center) {
      right.first = sign(right.first) * (end - center);
      right.second = 0;
    } else if (abs(right.second) + abs(right.first) > end - center) {
      right.second = sign(right.second) * (end - center - abs(right.first));
    }
    mergeSegments(left, right, true);
    for (int i = 0; i < k; ++i) {
      r = max(r, abs(buffer[i]));
      if (i > 0 && buffer[i - 1] > 0 && buffer[i] < 0) {
        r = max(r, buffer[i - 1] - buffer[i]);
      }
    }
  }
  return r;
}
int main() {
  int n, q;
  cin >> n >> q;
  string str;
  cin >> str;
  left_two_segments.resize(n * 4);
  right_two_segments.resize(n * 4);
  max_sink_distances.resize(n * 4);
  max_source_distances.resize(n * 4);
  swaps.resize(n * 4);
  build(0, 0, str.size(), str);
  while (q-- > 0) {
    int start, end;
    cin >> start >> end;
    --start;
    cout << queryAndReverse(start, end, 0, 0, str.length()) << endl;
  }
  return 0;
}