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 JAVA):

Solution:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.ArrayList;
import java.util.List;


public class RagingThunder {
    public static void main(String[] args) throws Exception{
        StreamTokenizer cin = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));

        cin.nextToken();
        int n = (int)cin.nval;
        cin.nextToken();
        int q = (int)cin.nval;
        cin.wordChars('<','>');
        cin.nextToken();
        
        String str = cin.sval;
        MySegmentTree segtree = new MySegmentTree(n,str);
        segtree.init();
        for (int i = 1;i <= q;i++){
            cin.nextToken();
            int l = (int)cin.nval;
            cin.nextToken();
            int r = (int)cin.nval;
            System.out.println(segtree.query(l,r));
        }
    }
}

class MySegmentTree {
    String str;
    int n;
    List<MyPair> list = new ArrayList<MyPair>();
    MySegmentTree(){
    }
    MySegmentTree(int len,String str){
        this.n = len;
        this.str = str;
    }
    public void init(){
        list.add(new MyPair());
        for (int i = 0;i < n+n;i++)
            list.add(new MyPair());
        init(1,1,n);
        build(1,1,n);
    }
    private void init(int p,int l,int r){
        list.add(new MyPair());
        if (l == r) return;
        int mid = (l + r) >> 1;
        init(p<<1,l,mid);
        init(p<<1|1,mid+1,r);       
    }
    private void build(int p,int l,int r){

        if (l == r){

            if (str.charAt(l-1) == '<') 
                list.get(p).setF(0);
            else 
                list.get(p).setF(1);
            return;
        }
        int mid = (l + r) >> 1;
        build(p<<1,l,mid);
        build(p<<1|1,mid+1,r);
        merge(p);
    }
    public int query(int l,int r){
        reverse(1,1,n,l,r);
        MyNode ret = getAns(1,1,n,l,r);
        
        int ans = ret.mx;
        /*
        MyNode fake;
        if (l == 1) ans = Math.max(ans,ret.ll);
        else {
            fake = getAns(1,1,n,l-1,r);
            if (fake.mx > ans) ans = fake.mx-1;
        }
        if (r == n) ans = Math.max(ans,ret.rr);
        else {
            fake = getAns(1,1,n,l,r+1);
            // System.out.println(fake.mx);
            if (fake.mx > ans) ans = fake.mx-1;
        }
        */
        ans = Math.max(ans,Math.max(ret.ll,ret.rr));
        
        return ans;
    }
    private void reverse(int p,int l,int r,int x,int y){
        if (l == x && r == y){
            list.get(p).reverse();
            return;
        }
        pushdown(p);
        int mid = l + r >> 1;
        if (y <= mid) reverse(p<<1,l,mid,x,y);
        else if (mid < x) reverse(p<<1|1,mid+1,r,x,y);
        else{
            reverse(p<<1,l,mid,x,mid);
            reverse(p<<1|1,mid+1,r,mid+1,y);
        }
        merge(p);
    }
    MyNode getAns(int p,int l,int r,int x,int y){
        if (l == x && r == y){
            return list.get(p).node[0];
        }
        int mid = l + r >> 1;
        pushdown(p);
        MyNode ans;
        if (y <= mid) ans = getAns(p<<1,l,mid,x,y);
        else if (mid < x) ans = getAns(p<<1|1, mid+1, r, x, y);
        else {
            ans = merge(getAns(p<<1, l, mid, x, mid),getAns(p<<1|1, mid+1, r, mid+1, y));
        }
        merge(p);
        // System.out.printf("%d %d %d %d %d\n", p,l,r,x,y);
        // System.out.printf("%d %d %d %d %d %b\n", ans.ll,ans.lr,ans.rl,ans.rr,ans.mx,ans.isconnected);
        return ans;
    }

    private void pushdown(int p){
        if (list.get(p).tag){
            int u = p<<1,v = p<<1|1;
            list.get(p).tag = false;
            if (u < list.size()) {
                list.get(u).reverse();
            }
            if (v < list.size()) {
                list.get(v).reverse();
            }
        }
    }
    //unfinish
    private MyNode merge(MyNode a,MyNode b){
        MyNode c = new MyNode();
        c.merge(a,b);
        return c;
    }

    //rewrite
    private void merge(int p){
        list.get(p).merge(list.get(p<<1),list.get(p<<1|1));
    }
}

class MyPair{
    public MyNode[] node;
    public boolean tag;
    public MyPair(){
        this.node = new MyNode[2];
        node[0] = new MyNode();
        node[1] = new MyNode();
        this.tag = false;
    }
    public void reverse(){
        tag = !tag;
        MyNode temp = node[0];
        this.node[0] = node[1];
        node[1] = temp;
    }
    public void setF(int opt){

        this.node[opt].ll = 1;
        this.node[opt].rl = 1;
        this.node[opt].lr = 0;
        this.node[opt].rr = 0;
        this.node[opt].mx = 0;
        this.node[opt].isconnected = true;

        this.node[opt^1].ll = 0;
        this.node[opt^1].rl = 0;
        this.node[opt^1].lr = 1;
        this.node[opt^1].rr = 1;
        this.node[opt^1].mx = 0;
        this.node[opt^1].isconnected = true;
    }
    public void merge(MyPair u,MyPair v){
        node[0].merge(u.node[0],v.node[0]);
        node[1].merge(u.node[1],v.node[1]);
    }
}

class MyNode{
    public int ll,lr,rl,rr,mx;
    public boolean isconnected;
    MyNode(){
        this.ll = this.lr = this.rl = this.rr = this.mx = 0;
        this.isconnected = true;
    }
    public void merge(MyNode u,MyNode v){
        int mx = Math.max(u.mx,v.mx);
        if (u.rr > 0 && v.ll > 0) mx = Math.max(mx, u.rr+v.ll);
        if (!u.isconnected || u.lr > 0) mx = Math.max(mx,u.rl + v.ll);
        if (!v.isconnected || v.rl > 0) mx = Math.max(mx,u.rr + v.lr);
        this.mx = mx;

        this.isconnected = 
            u.isconnected && v.isconnected && 
            ((u.rr > 0 && v.ll > 0) || (u.rr > 0 && v.lr > 0) || (u.rl > 0 && v.ll > 0));
        // if (u.rl == 1)
        // System.out.printf("isconnect %b %b %d %d\n", this.isconnected,v.isconnected,u.rl,v.ll);
        if (this.isconnected){
            if (u.ll > 0) {
                this.ll = u.ll + v.ll;
                this.lr = 0;
            }
            if (u.lr > 0) {
                this.lr = u.lr + v.ll + v.lr;
                this.ll = 0;
            }
            if (v.rl > 0){

                this.rl = v.rl + u.rl + u.rr;
                this.rr = 0; 
            }
            if (v.rr > 0){
                this.rr = v.rr + u.rr;
                this.rl = 0;
            }
        }
        else if (u.isconnected){
            if (u.rr > 0){
                this.lr = u.lr + v.lr + v.ll;
                this.ll = 0;
            }
            else if (u.ll > 0){
                this.ll = u.ll + v.ll;
                this.lr = 0;
            }
            else {
                this.lr = u.lr + v.ll;
                this.ll = 0;
            }
            
            this.rl = v.rl;
            this.rr = v.rr;            
        }
        else if (v.isconnected){
            this.ll = u.ll;
            this.lr = u.lr;
            
            if (v.ll > 0){
                this.rl = v.ll + u.rl + u.rr;
                this.rr = 0;
            }
            else if (v.rr > 0){
                this.rr = u.rr + v.rr;
                this.rl = 0;
            }
            else{
                this.rl = v.rl + u.rr;
                this.rr = 0;
            }
        }
        else {
            this.ll = u.ll;
            this.lr = u.lr;
            this.rl = v.rl;
            this.rr = v.rr;
        }
    }
}