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 best[2][2], pref[2][2], suf[2][2], all[2][2];
  int sz;
  Node(int x) {
    for (int i = 0; i < 2; ++i) {
      for (int j = 0; j < 2; ++j) {
        best[i][j] = pref[i][j] = suf[i][j] = all[i][j] = 0;
      }
    }
    best[0][x] = best[1][x] = best[x][0] = best[x][1] = 1;
    pref[0][x] = pref[1][x] = pref[x][0] = pref[x][1] = 1;
    suf[0][x] = suf[1][x] = suf[x][0] = suf[x][1] = 1;
    all[0][x] = all[1][x] = all[x][0] = all[x][1] = 1;
    sz = 1;
  }
  Node() {
    for (int i = 0; i < 2; ++i) {
      for (int j = 0; j < 2; ++j) {
        best[i][j] = pref[i][j] = suf[i][j] = all[i][j] = 0;
      }
    }
    sz = 0;
    for (int i = 0; i < 2; ++i) {
      for (int j = 0; j < 2; ++j) {
        all[i][j] = 1;
      }
    }
  }
  Node rev() const {
    Node res;
    res.sz = sz;
    for (int i = 0; i < 2; ++i) {
      for (int j = 0; j < 2; ++j) {
        res.best[i][j] = best[i ^ 1][j ^ 1];
      }
    }
    for (int i = 0; i < 2; ++i) {
      for (int j = 0; j < 2; ++j) {
        res.pref[i][j] = pref[i ^ 1][j ^ 1];
      }
    }
    for (int i = 0; i < 2; ++i) {
      for (int j = 0; j < 2; ++j) {
        res.suf[i][j] = suf[i ^ 1][j ^ 1];
      }
    }
    for (int i = 0; i < 2; ++i) {
      for (int j = 0; j < 2; ++j) {
        res.all[i][j] = all[i ^ 1][j ^ 1];
      }
    }
    return res;
  }
  Node operator+(const Node &other) const {
    Node res;
    res.sz = sz + other.sz;
    for (int i = 0; i < 2; ++i) {
      for (int j = 0; j < 2; ++j) {
        res.best[i][j] = max(best[i][j], other.best[i][j]);
      }
    }
    for (int i = 0; i < 2; ++i) {
      for (int j = 0; j < 2; ++j) {
        res.best[i][j] = max(res.best[i][j], suf[i][i] + other.pref[i][j]);
        res.best[i][j] = max(res.best[i][j], suf[i][j] + other.pref[j][j]);
      }
    }
    for (int i = 0; i < 2; ++i) {
      for (int j = 0; j < 2; ++j) {
        res.pref[i][j] = pref[i][j] + (all[i][j] ? other.pref[j][j] : 0);
        if (all[i][i]) {
          res.pref[i][j] = max(res.pref[i][j], pref[i][i] + other.pref[i][j]);
        }
      }
    }
    for (int i = 0; i < 2; ++i) {
      for (int j = 0; j < 2; ++j) {
        res.suf[i][j] = other.suf[i][j] + (other.all[i][j] ? suf[i][i] : 0);
        if (other.all[j][j]) {
          res.suf[i][j] = max(res.suf[i][j], other.suf[j][j] + suf[i][j]);
        }
      }
    }
    for (int i = 0; i < 2; ++i) {
      for (int j = 0; j < 2; ++j) {
        if (res.best[i][j] == res.sz) {
          res.all[i][j] = 1;
        } else {
          res.all[i][j] = 0;
        }
      }
    }
    return res;
  }
};
const int N = 5e5 + 7;
Node t[4 * N];
int mod[4 * N];
void build(int l, int r, int v, vector<int> &a) {
  if (l == r) {
    t[v] = Node(a[l]);
  } else {
    int m = (l + r) >> 1;
    build(l, m, 2 * v + 1, a);
    build(m + 1, r, 2 * v + 2, a);
    t[v] = t[2 * v + 1] + t[2 * v + 2];
  }
}
void update(int v) {
  t[v] = t[v].rev();
  mod[v] ^= 1;
}
void push(int v) {
  if (mod[v]) {
    update(2 * v + 1);
    update(2 * v + 2);
    mod[v] = 0;
  }
}
void modify(int ql, int qr, int l, int r, int v) {
  if (qr < l || r < ql) return;
  if (ql <= l && r <= qr) {
    update(v);
  } else {
    push(v);
    int m = (l + r) >> 1;
    modify(ql, qr, l, m, 2 * v + 1);
    modify(ql, qr, m + 1, r, 2 * v + 2);
    t[v] = t[2 * v + 1] + t[2 * v + 2];
  }
}
Node get(int ql, int qr, int l, int r, int v) {
  if (qr < l || r < ql) return Node();
  if (ql <= l && r <= qr) return t[v];
  push(v);
  int m = (l + r) >> 1;
  return get(ql, qr, l, m, 2 * v + 1) + get(ql, qr, m + 1, r, 2 * v + 2);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  {
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
      if (s[i] == '>')
        a[i] = 0;
      else
        a[i] = 1;
    }
    build(0, n - 1, 0, a);
  }
  while (q--) {
    int l, r;
    cin >> l >> r;
    --l, --r;
    modify(l, r, 0, n - 1, 0);
    auto res = get(l, r, 0, n - 1, 0);
    cout << res.best[0][1] << '\n';
  }
}