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>
const int MAX_N = 500000;
struct SegTree {
  bool inverted;
  int size;
  int in[2][2];
  int pref[2][2];
  int suff[2][2];
};
char s[MAX_N + 1];
SegTree segTree[1 << 20];
SegTree join(SegTree left, SegTree right) {
  SegTree answer;
  answer.inverted = false;
  answer.size = left.size + right.size;
  for (int a : {0, 1}) {
    for (int b : {0, 1}) {
      answer.in[a][b] = std::max(left.in[a][b], right.in[a][b]);
      answer.pref[a][b] = left.pref[a][b];
      answer.suff[a][b] = right.suff[a][b];
    }
  }
  for (int a : {0, 1}) {
    for (int b : {0, 1}) {
      for (int c : {0, 1}) {
        for (int d : {0, 1}) {
          if ((a <= b && b <= c && c <= d) || (a >= b && b >= c && c >= d)) {
            answer.in[a][d] =
                std::max(answer.in[a][d], left.suff[a][b] + right.pref[c][d]);
            if (left.pref[a][b] == left.size) {
              answer.pref[a][d] = std::max(answer.pref[a][d],
                                           left.pref[a][b] + right.pref[c][d]);
            }
            if (right.suff[c][d] == right.size) {
              answer.suff[a][d] = std::max(answer.suff[a][d],
                                           left.suff[a][b] + right.suff[c][d]);
            }
          }
        }
      }
    }
  }
  return answer;
}
void invert(int index) {
  SegTree &root = segTree[index];
  root.inverted ^= 1;
  for (int a : {0, 1}) {
    std::swap(root.in[a][0], root.in[1 - a][1]);
    std::swap(root.pref[a][0], root.pref[1 - a][1]);
    std::swap(root.suff[a][0], root.suff[1 - a][1]);
  }
}
void propagate(int index) {
  if (segTree[index].inverted) {
    segTree[index].inverted = false;
    if (index < (1 << 19)) {
      invert(2 * index);
      invert(2 * index + 1);
    }
  }
}
void build(int index, int sL, int sR) {
  if (sL == sR) {
    int val = s[sL];
    segTree[index].size = 1;
    segTree[index].in[val][val] = 1;
    segTree[index].pref[val][val] = 1;
    segTree[index].suff[val][val] = 1;
  } else {
    int mid = (sL + sR) / 2;
    build(2 * index, sL, mid);
    build(2 * index + 1, mid + 1, sR);
    segTree[index] = join(segTree[2 * index], segTree[2 * index + 1]);
  }
}
void print(int index, int sL, int sR) {
  propagate(index);
  if (sL == sR) {
    for (int val : {0, 1}) {
      if (segTree[index].in[val][val] == 1) {
        printf("%d", val);
      }
      if (segTree[index].pref[val][val] == 1) {
        printf("%d", val);
      }
      if (segTree[index].suff[val][val] == 1) {
        printf("%d", val);
      }
    }
  } else {
    int mid = (sL + sR) / 2;
    print(2 * index, sL, mid);
    print(2 * index + 1, mid + 1, sR);
  }
}
SegTree query(int index, int sL, int sR, int qL, int qR) {
  SegTree answer;
  if (sL == qL && sR == qR) {
    invert(index);
    propagate(index);
    answer = segTree[index];
  } else {
    propagate(index);
    int mid = (sL + sR) / 2;
    if (qR <= mid) {
      answer = query(2 * index, sL, mid, qL, qR);
    } else if (mid + 1 <= qL) {
      answer = query(2 * index + 1, mid + 1, sR, qL, qR);
    } else {
      answer = join(query(2 * index, sL, mid, qL, mid),
                    query(2 * index + 1, mid + 1, sR, mid + 1, qR));
    }
    segTree[index] = join(segTree[2 * index], segTree[2 * index + 1]);
  }
  return answer;
}
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  scanf("%s", s);
  for (int i = 0; s[i] != '\0'; i++) {
    if (s[i] == '>') {
      s[i] = 0;
    } else if (s[i] == '<') {
      s[i] = 1;
    }
  }
  build(1, 0, n - 1);
  for (int i = 0; i < q; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    l--;
    r--;
    SegTree q = query(1, 0, n - 1, l, r);
    int answer = std::max(std::max(q.in[0][0], q.in[0][1]), q.in[1][1]);
    printf("%d\n", answer);
  }
  return 0;
}