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;
namespace Fread {
const int SIZE = 1 << 20;
char buf[SIZE], *S, *T;
inline char getchar() {
  if (S == T) {
    T = (S = buf) + fread(buf, 1, SIZE, stdin);
    if (S == T) return EOF;
  }
  return *S++;
}
}  // namespace Fread
namespace Fwrite {
const int SIZE = 1 << 20;
char buf[SIZE], *S = buf, *T = buf + SIZE;
inline void flush() {
  fwrite(buf, 1, S - buf, stdout);
  S = buf;
}
inline void putchar(char c) {
  *S++ = c;
  if (S == T) flush();
}
struct _ {
  ~_() { flush(); }
} __;
}  // namespace Fwrite
template <typename T>
inline void read(T& x) {
  x = 0;
  int f = 1;
  char c = Fread::getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = Fread::getchar();
  }
  while (isdigit(c)) x = x * 10 + (c - '0'), c = Fread::getchar();
  x *= f;
}
template <typename T>
inline void write(T x, bool _enter = 0, bool _space = 0) {
  if (!x)
    Fwrite::putchar('0');
  else {
    if (x < 0) Fwrite::putchar('-'), x = -x;
    static char dig[41];
    int top = 0;
    while (x) dig[++top] = (x % 10) + '0', x /= 10;
    while (top) Fwrite::putchar(dig[top--]);
  }
  if (_enter) Fwrite::putchar('\n');
  if (_space) Fwrite::putchar(' ');
}
namespace Fastio {
struct reader {
  template <typename T>
  reader& operator>>(T& x) {
    ::read(x);
    return *this;
  }
  reader& operator>>(char& c) {
    c = Fread::getchar();
    while (c == '\n' || c == ' ') c = Fread::getchar();
    return *this;
  }
  reader& operator>>(char* str) {
    int len = 0;
    char c = Fread::getchar();
    while (c == '\n' || c == ' ') c = Fread::getchar();
    while (c != '\n' && c != ' ') str[len++] = c, c = Fread::getchar();
    str[len] = '\0';
    return *this;
  }
} cin;
const char endl = '\n';
struct writer {
  template <typename T>
  writer& operator<<(T x) {
    ::write(x, 0, 0);
    return *this;
  }
  writer& operator<<(char c) {
    Fwrite::putchar(c);
    return *this;
  }
  writer& operator<<(const char* str) {
    int cur = 0;
    while (str[cur]) Fwrite::putchar(str[cur++]);
    return *this;
  }
} cout;
}  // namespace Fastio
const int MAXN = 5e5;
int n, q;
char s[MAXN + 5];
struct RangeInfo {
  int left_down, left_up;
  int right_down, right_up;
  int ans;
  RangeInfo() { left_down = left_up = right_down = right_up = ans = 0; }
};
RangeInfo merge(const RangeInfo& a, const RangeInfo& b) {
  RangeInfo res;
  res.left_down = a.left_down;
  res.left_up = a.left_up;
  res.right_down = b.right_down;
  res.right_up = b.right_up;
  res.ans = max(a.ans, b.ans);
  if (a.right_up) {
    assert(a.right_down != 0);
    if (b.left_down) {
      res.ans = max(res.ans, a.right_down + a.right_up);
      if (b.left_up) {
        if (b.right_down)
          res.ans = max(res.ans, b.left_down + b.left_up);
        else {
          res.right_down = b.left_down;
          res.right_up = b.left_up;
        }
      } else {
        res.right_down = b.left_down;
      }
    } else {
      assert(b.left_up != 0);
      if (b.right_down) {
        res.ans = max(res.ans, a.right_down + a.right_up + b.left_up);
      } else {
        res.right_down = a.right_down;
        res.right_up = a.right_up + b.left_up;
      }
    }
  } else {
    if (a.right_down) {
      if (b.left_down) {
        if (b.left_up) {
          if (b.right_down)
            res.ans = max(res.ans, a.right_down + b.left_down + b.left_up);
          else {
            res.right_down = a.right_down + b.left_down;
            res.right_up = b.left_up;
          }
        } else {
          res.right_down = a.right_down + b.left_down;
        }
      } else {
        assert(b.left_up != 0);
        if (b.right_down)
          res.ans = max(res.ans, a.right_down + b.left_up);
        else {
          res.right_down = a.right_down;
          res.right_up = b.left_up;
        }
      }
    } else {
      if (a.left_down) {
        if (a.left_up) {
          if (b.left_down) {
            if (b.left_up) {
              if (b.right_down)
                res.ans = max(res.ans, b.left_down + b.left_up);
              else {
                res.right_down = b.left_down;
                res.right_up = b.left_up;
              }
            } else {
              res.right_down = b.left_down;
            }
          } else {
            assert(b.left_up != 0);
            res.left_up = a.left_up + b.left_up;
          }
        } else {
          res.left_down = a.left_down + b.left_down;
          res.left_up = b.left_up;
        }
      } else {
        assert(a.left_up != 0);
        if (b.left_down) {
          if (b.left_up) {
            if (b.right_down)
              res.ans = max(res.ans, b.left_down + b.left_up);
            else {
              res.right_down = b.left_down;
              res.right_up = b.left_up;
            }
          } else {
            res.right_down = b.left_down;
          }
        } else {
          assert(b.left_up != 0);
          res.left_up = a.left_up + b.left_up;
        }
      }
    }
  }
  return res;
}
int getans(const RangeInfo& a) {
  int ans = a.ans;
  ans = max(ans, a.left_down + a.left_up);
  ans = max(ans, a.right_down + a.right_up);
  return ans;
}
struct SegmentTree {
  RangeInfo cur[MAXN * 4 + 5], rev[MAXN * 4 + 5];
  bool tag[MAXN * 4 + 5];
  void push_up(int p) {
    cur[p] = merge(cur[p << 1], cur[p << 1 | 1]);
    rev[p] = merge(rev[p << 1], rev[p << 1 | 1]);
  }
  void build(int p, int l, int r) {
    if (l == r) {
      if (s[l] == '>') {
        cur[p].left_down = 1;
        rev[p].left_up = 1;
      } else {
        cur[p].left_up = 1;
        rev[p].left_down = 1;
      }
      return;
    }
    int mid = (l + r) >> 1;
    build(p << 1, l, mid);
    build(p << 1 | 1, mid + 1, r);
    push_up(p);
  }
  void upd(int p) {
    tag[p] ^= 1;
    swap(cur[p], rev[p]);
  }
  void push_down(int p) {
    if (tag[p]) {
      upd(p << 1);
      upd(p << 1 | 1);
      tag[p] = 0;
    }
  }
  void modify(int p, int l, int r, int ql, int qr) {
    if (ql <= l && qr >= r) {
      upd(p);
      return;
    }
    int mid = (l + r) >> 1;
    push_down(p);
    if (ql <= mid) modify(p << 1, l, mid, ql, qr);
    if (qr > mid) modify(p << 1 | 1, mid + 1, r, ql, qr);
    push_up(p);
  }
  RangeInfo Q_res;
  bool flag;
  void query(int p, int l, int r, int ql, int qr) {
    if (ql <= l && qr >= r) {
      if (!flag) {
        Q_res = cur[p];
        flag = 1;
      } else
        Q_res = merge(Q_res, cur[p]);
      return;
    }
    int mid = (l + r) >> 1;
    push_down(p);
    if (ql <= mid) query(p << 1, l, mid, ql, qr);
    if (qr > mid) query(p << 1 | 1, mid + 1, r, ql, qr);
    push_up(p);
  }
  RangeInfo query(int l, int r) {
    Q_res = RangeInfo();
    flag = 0;
    query(1, 1, n, l, r);
    return Q_res;
  }
} T;
int main() {
  Fastio::cin >> n >> q;
  Fastio::cin >> (s + 1);
  T.build(1, 1, n);
  while (q--) {
    int l, r;
    Fastio::cin >> l >> r;
    T.modify(1, 1, n, l, r);
    RangeInfo res = T.query(l, r);
    Fastio::cout << getans(res) << Fastio::endl;
  }
  return 0;
}