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 javafx.beans.property.IntegerProperty;

import java.util.*;
import java.io.*;

public class RagingThunder {
    public static void main(String[] args) throws IOException{
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        StringTokenizer st = new StringTokenizer(f.readLine());
        int n = Integer.parseInt(st.nextToken());
        int q = Integer.parseInt(st.nextToken());
        String str = f.readLine();
        SegmentTree segtree = new SegmentTree(n, str);
        for(int i = 0; i < q; i++){
            st = new StringTokenizer(f.readLine());
            int a = Integer.parseInt(st.nextToken())-1;
            int b = Integer.parseInt(st.nextToken())-1;
            segtree.update(a, b);
            out.println(segtree.query(a, b));
        }
        out.close();

    }
    static class SegmentTree
    {
        //range query, non lazy
        final int[] val;
        final int[] invval;
        final int[] leftmax;
        final int[] invleftmax;
        final int[] rightmax;
        final int[] invrightmax;
        final boolean[] lazy;
        final boolean[] leftchar;
        final boolean[] rightchar;
        final boolean[] invleftchar;
        final boolean[] invrightchar;
        final String str;
        final int length;
        final int n;

        public SegmentTree(int n, String str)
        {
            this.n = n;
            int l;
            for (l = 0; (1 << l) < n; l++);
            val = new int[1 << (l + 1)];
            invval = new int[1 << (l+1)];
            leftmax = new int[1 << (l+1)];
            rightmax = new int[1 << (l+1)];
            invleftmax =new int[1 << (l+1)];
            invrightmax = new int[1 << (l+1)];
            lazy = new boolean[1 << (l+1)];
            leftchar = new boolean[1 << (l+1)];
            rightchar = new boolean[1 << (l+1)];
            invleftchar = new boolean[1 << (l+1)];
            invrightchar = new boolean[1 << (l+1)];
            this.str = str;
            this.length = 1 << l;
            prec(0, n-1, 0);
        }
        public void prec(int l, int r, int idx){
            if(l == r){
                val[idx] = 1;
                invval[idx] = 1;
                leftmax[idx] = 1;
                rightmax[idx] = 1;
                invleftmax[idx] = 1;
                invrightmax[idx] = 1;
                if(str.charAt(l) == '<'){
                    leftchar[idx] = false;
                    rightchar[idx] = false;
                    invleftchar[idx] = true;
                    invrightchar[idx] = true;
                }else{
                    leftchar[idx] = true;
                    rightchar[idx] = true;
                    invleftchar[idx] = false;
                    invrightchar[idx] = false;
                }
                return;
            }
            int mid = (l+r)/2;
            prec(l, mid, (2*idx)+1);
            prec(mid+1, r, (2*idx)+2);
            comb(idx, (2*idx)+1, (2*idx+2), l, mid, r);
        }
        public void update(int from, int to)
        {
            updateRecur(from, to, 0, n-1, 0);
        }
        public void updateRecur(int from, int to, int l, int r, int idx){
            if(lazy[idx]){
                swap(idx);
                if(l != r){
                    lazy[(2*idx) + 1] = !lazy[(2*idx) + 1];
                    lazy[(2*idx) + 2] = !lazy[(2*idx) + 2];
                }
                lazy[idx] = false;
            }
            if(from > to || l > to || r < from){
                return;
            }
            if(l >= from && r <= to){
                swap(idx);
                if(l != r){
                    lazy[(2*idx) + 1] = !lazy[(2*idx) + 1];
                    lazy[(2*idx) + 2] = !lazy[(2*idx) + 2];
                }
                return;
            }

            int mid = (l+r)/2;
            updateRecur(from, to, l, mid, (2*idx)+1);
            updateRecur(from, to, mid+1, r, (2*idx)+2);

            comb(idx, (2*idx)+1, (2*idx)+2, l, mid, r);

        }
        public int query(int from, int to)
        {
            return queryRecur(from, to, 0, n-1, 0).val;
        }
        public SixTuple queryRecur(int from, int to, int l, int r, int idx){
            if(lazy[idx]){
                swap(idx);
                if(l != r){
                    lazy[(2*idx) + 1] = !lazy[(2*idx) + 1];
                    lazy[(2*idx) + 2] = !lazy[(2*idx) + 2];
                }
                lazy[idx] = false;
            }
            if(from > to || l > to || r < from){
                return null;
            }
            if(l >= from && r <= to){
                return new SixTuple(val[idx], leftmax[idx], rightmax[idx], leftchar[idx], rightchar[idx], (r-l)+1);
            }

            int mid = (l+r)/2;
            SixTuple first = queryRecur(from, to, l, mid, (2*idx)+1);
            SixTuple second = queryRecur(from, to, mid+1, r, (2*idx)+2);
            if(first == null) return second;
            if(second == null) return first;
            return combine(first, second);


        }
        public SixTuple combine(SixTuple a, SixTuple b){
            SixTuple ret = new SixTuple(0, 0, 0, false, false, 0);
            int ans = Math.max(a.val, b.val);
            //take rightmax of a and leftmax of b
            //if the rightmost character of a is '>' ('true'), then combine it no matter what
            //otherwise, if it is '<' ('false'), combine it only if the leftmost character of b is '<' ('false')
            int cons = 0;
            if(a.rightchar){
                cons = a.rightmax+b.leftmax;
            }else if(!b.leftchar){
                cons = a.rightmax+b.leftmax;
            }
            ans = Math.max(ans, cons);

            //update values
            ret.val = ans;

            //left and right characters are easy
            ret.leftchar = a.leftchar;
            ret.rightchar = b.rightchar;

            //lengths are a bit trickier
            //if the length of the leftmost prefix was equal to the length of the segment, and the rightmost segment
            //was compatible, then we need to add the length of the right prefix to the left
            //otherwise, just keep it the same
            if(a.leftmax == a.length && (a.rightchar || !b.leftchar)){
                ret.leftmax = a.leftmax+b.leftmax;
            }else{
                ret.leftmax = a.leftmax;
            }

            //now do it for the right
            if(b.rightmax == b.length && (a.rightchar || !b.leftchar)){
                ret.rightmax = b.rightmax+a.rightmax;
            }else{
                ret.rightmax = b.rightmax;
            }

            //and now we're good
            ret.length = a.length+b.length;
            return ret;

        }
        public void comb(int node, int a, int b, int l, int mid, int r)
        {
            int ans = Math.max(val[a], val[b]);
            int invans = Math.max(invval[a], invval[b]);

            //take rightmax of a and leftmax of b
            //if the rightmost character of a is '>' ('true'), then combine it no matter what
            //otherwise, if it is '<' ('false'), combine it only if the leftmost character of b is '<' ('false')
            int cons = 0;
            if(rightchar[a]){
                cons = rightmax[a]+leftmax[b];
            }else if(!leftchar[b]){
                cons = rightmax[a]+leftmax[b];
            }
            ans = Math.max(ans, cons);

            //now do the same thing but for the inverse
            int invcons = 0;
            if(invrightchar[a]){
                invcons = invrightmax[a]+invleftmax[b];
            }else if(!invleftchar[b]){
                invcons = invrightmax[a]+invleftmax[b];
            }
            invans = Math.max(invans, invcons);

            //update values
            val[node] = ans;
            invval[node] = invans;

            //left and right characters are easy
            leftchar[node] = leftchar[a];
            rightchar[node] = rightchar[b];
            invleftchar[node] = invleftchar[a];
            invrightchar[node] = invrightchar[b];

            //lengths are a bit trickier
            //if the length of the leftmost prefix was equal to the length of the segment, and the rightmost segment
            //was compatible, then we need to add the length of the right prefix to the left
            //otherwise, just keep it the same
            if(leftmax[a] == (mid-l+1) && (rightchar[a] || !leftchar[b])){
                leftmax[node] = leftmax[a]+leftmax[b];
            }else{
                leftmax[node] = leftmax[a];
            }
            //same for the inverse
            if(invleftmax[a] == (mid-l+1) && (invrightchar[a] || !invleftchar[b])){
                invleftmax[node] = invleftmax[a]+invleftmax[b];
            }else{
                invleftmax[node] = invleftmax[a];
            }

            //now do it for the right and its inverse
            if(rightmax[b] == (r-mid) && (rightchar[a] || !leftchar[b])){
                rightmax[node] = rightmax[b]+rightmax[a];
            }else{
                rightmax[node] = rightmax[b];
            }

            if(invrightmax[b] == (r-mid) && (invrightchar[a] || !invleftchar[b])){
                invrightmax[node] = invrightmax[b]+invrightmax[a];
            }else{
                invrightmax[node] = invrightmax[b];
            }

            //and now we're good
        }
        public void swap(int a){
            int temp1 = val[a];
            int temp2 = leftmax[a];
            int temp3 = rightmax[a];
            boolean temp4 = leftchar[a];
            boolean temp5 = rightchar[a];
            val[a] = invval[a];
            leftmax[a] = invleftmax[a];
            rightmax[a] = invrightmax[a];
            leftchar[a] = invleftchar[a];
            rightchar[a] = invrightchar[a];
            invval[a] = temp1;
            invleftmax[a] = temp2;
            invrightmax[a] = temp3;
            invleftchar[a] = temp4;
            invrightchar[a] = temp5;
        }
    }
    static class SixTuple{
        public int val;
        public int leftmax;
        public int rightmax;
        public boolean leftchar;
        public boolean rightchar;
        public int length;

        public SixTuple(int a, int b, int c, boolean d, boolean e, int f){
            val=a;
            leftmax=b;
            rightmax=c;
            leftchar=d;
            rightchar=e;
            length=f;
        }
    }
}