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;
const int N = 500050;
struct node {
  int ll, lr, rl, rr, li, lo, ri, ro, mi, mo;
  int len;
  int flip;
  node()
      : ll(0),
        lr(0),
        rl(0),
        rr(0),
        li(0),
        lo(0),
        ri(0),
        ro(0),
        mi(0),
        mo(0),
        len(0),
        flip(0) {}
  node(int ll, int lr, int rl, int rr, int li, int lo, int ri, int ro, int mi,
       int mo, int len, int flip)
      : ll(ll),
        lr(lr),
        rl(rl),
        rr(rr),
        li(li),
        lo(lo),
        ri(ri),
        ro(ro),
        mi(mi),
        mo(mo),
        len(len),
        flip(flip) {}
  void print() {
    cout << "ll = " << ll << " lr = " << lr << " rl = " << rl << " rr = " << rr
         << " lo = " << lo << " li = " << li << " ro = " << ro << " ri = " << ri
         << " mo = " << mo << " mi = " << mi << '\n';
  }
} tree[4 * N];
int ll(node x) {
  if (x.flip) {
    return x.lr;
  }
  return x.ll;
}
int lr(node x) {
  if (x.flip) {
    return x.ll;
  }
  return x.lr;
}
int rl(node x) {
  if (x.flip) {
    return x.rr;
  }
  return x.rl;
}
int rr(node x) {
  if (x.flip) {
    return x.rl;
  }
  return x.rr;
}
int li(node x) {
  if (x.flip) {
    return x.lo;
  }
  return x.li;
}
int lo(node x) {
  if (x.flip) {
    return x.li;
  }
  return x.lo;
}
int ri(node x) {
  if (x.flip) {
    return x.ro;
  }
  return x.ri;
}
int ro(node x) {
  if (x.flip) {
    return x.ri;
  }
  return x.ro;
}
int mi(node x) {
  if (x.flip) {
    return x.mo;
  }
  return x.mi;
}
int mo(node x) {
  if (x.flip) {
    return x.mi;
  }
  return x.mo;
}
int len(node x) { return x.len; }
inline int merge_li(node a, node b) {
  assert(lr(a) <= len(a));
  if (lr(a) == len(a)) {
    if (li(b) > 0) {
      return lr(a) + li(b);
    } else if (ll(b) > 0) {
      return lr(a) + ll(b);
    }
  }
  assert(li(a) <= len(a));
  if (li(a) == len(a)) {
    return li(a) + ll(b);
  }
  return li(a);
}
inline int merge_ri(node a, node b) {
  assert(rl(b) <= len(b));
  if (rl(b) == len(b)) {
    if (ri(a) > 0) {
      return rl(b) + ri(a);
    } else if (rr(a) > 0) {
      return rl(b) + rr(a);
    }
  }
  assert(ri(b) <= len(b));
  if (ri(b) == len(b)) {
    return ri(b) + rr(a);
  }
  return ri(b);
}
inline int merge_lo(node a, node b) {
  assert(ll(a) <= len(a));
  if (ll(a) == len(a)) {
    if (lo(b) > 0) {
      return ll(a) + lo(b);
    } else if (lr(b) > 0) {
      return ll(a) + lr(b);
    }
  }
  assert(lo(a) <= len(a));
  if (lo(a) == len(a)) {
    return lo(a) + lr(b);
  }
  return lo(a);
}
inline int merge_ro(node a, node b) {
  assert(rr(b) <= len(b));
  if (rr(b) == len(b)) {
    if (ro(a) > 0) {
      return rr(b) + ro(a);
    } else if (rl(a) > 0) {
      return rr(b) + rl(a);
    }
  }
  assert(ro(b) <= len(b));
  if (ro(b) == len(b)) {
    return ro(b) + rl(a);
  }
  return ro(b);
}
inline int merge_mi(node x, node a, node b) {
  int ret = max(li(x), ri(x));
  ret = max(ret, max(mi(a), mi(b)));
  if (rr(a) > 0 && ll(b) > 0) {
    ret = max(ret, rr(a) + ll(b));
  }
  if (ri(a) > 0) {
    ret = max(ret, ri(a) + ll(b));
  }
  if (li(b) > 0) {
    ret = max(ret, rr(a) + li(b));
  }
  return ret;
}
inline int merge_mo(node x, node a, node b) {
  int ret = max(lo(x), ro(x));
  ret = max(ret, max(mo(a), mo(b)));
  if (rl(a) > 0 && lr(b) > 0) {
    ret = max(ret, rl(a) + lr(b));
  }
  if (lo(b) > 0) {
    ret = max(ret, rl(a) + lo(b));
  }
  if (ro(a) > 0) {
    ret = max(ret, ro(a) + lr(b));
  }
  return ret;
}
inline node merge(node a, node b) {
  node ret;
  ret.ll = ll(a) + (ll(a) == len(a)) * ll(b);
  ret.lr = lr(a) + (lr(a) == len(a)) * lr(b);
  ret.rl = rl(b) + (rl(b) == len(b)) * rl(a);
  ret.rr = rr(b) + (rr(b) == len(b)) * rr(a);
  ret.li = merge_li(a, b);
  ret.ri = merge_ri(a, b);
  ret.lo = merge_lo(a, b);
  ret.ro = merge_ro(a, b);
  ret.mi = merge_mi(ret, a, b);
  ret.mo = merge_mo(ret, a, b);
  ret.len = len(a) + len(b);
  return ret;
}
void build(int x, int l, int r, const string& s) {
  if (l == r) {
    tree[x] = node();
    if (s[l] == '<') {
      tree[x].ll = 1;
      tree[x].rl = 1;
    } else {
      tree[x].lr = 1;
      tree[x].rr = 1;
    }
    tree[x].len = 1;
    return;
  }
  int y = (l + r) >> 1;
  build(x + x, l, y, s);
  build(x + x + 1, y + 1, r, s);
  tree[x] = merge(tree[x + x], tree[x + x + 1]);
}
void push(int x) {
  if (tree[x].flip) {
    swap(tree[x].ll, tree[x].lr);
    swap(tree[x].rl, tree[x].rr);
    swap(tree[x].li, tree[x].lo);
    swap(tree[x].ri, tree[x].ro);
    swap(tree[x].mi, tree[x].mo);
    tree[x].flip = 0;
    tree[x + x].flip ^= 1;
    tree[x + x + 1].flip ^= 1;
  }
}
inline void pull(int x) { tree[x] = merge(tree[x + x], tree[x + x + 1]); }
node modify(int x, int l, int r, int ll, int rr) {
  if (ll <= l && r <= rr) {
    tree[x].flip ^= 1;
    return tree[x];
  }
  push(x);
  int y = (l + r) >> 1;
  node ret;
  if (ll <= y && y + 1 <= rr) {
    ret =
        merge(modify(x + x, l, y, ll, rr), modify(x + x + 1, y + 1, r, ll, rr));
  } else if (ll <= y) {
    ret = modify(x + x, l, y, ll, rr);
  } else if (y + 1 <= rr) {
    ret = modify(x + x + 1, y + 1, r, ll, rr);
  } else {
    assert(0);
  }
  pull(x);
  return ret;
}
int GetAns(node x) {
  if (x.flip) {
    return max(max(x.lr, x.rl), x.mo);
  }
  return max(max(x.ll, x.rr), x.mi);
}
void print(int x, int l, int r, const string& s) {
  for (int i = l; i <= r; i++) {
    cout << s[i];
  }
  if (l == r) {
    return;
  }
  int y = (l + r) >> 1;
  print(x + x, l, y, s);
  print(x + x + 1, y + 1, r, s);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  build(1, 0, n - 1, s);
  while (q--) {
    int l, r;
    cin >> l >> r;
    --l;
    --r;
    node ans = modify(1, 0, n - 1, l, r);
    assert(ans.len == r - l + 1);
    cout << GetAns(ans) << '\n';
  }
  return 0;
}