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.*;
import java.util.*;

/*
polyakoff
*/

public class Main {

    static FastReader in;
    static PrintWriter out;
    static Random rand = new Random();
    static final int oo = (int) 2e9;
    static final long OO = (long) 4e18;
    static final int MOD = (int) 1e9 + 7;


    static class SegTree {
        class Node {
            int rl, rlPre, rlSuf, lr, lrPre, lrSuf, len, lazy;
            char l, r;

            Node(char ss) {
                rl = rlPre = rlSuf = lr = lrPre = lrSuf = len = 1;
                lazy = 0;
                l = ss == '<' ? 'l' : 'r';
                r = l;
            }
            Node() {
            }

            void flip() {
                int temp;
                temp = rl; rl = lr; lr = temp;
                temp = rlPre; rlPre = lrPre; lrPre = temp;
                temp = rlSuf; rlSuf = lrSuf; lrSuf = temp;
                l = (char) ('l' + 'r' - l);
                r = (char) ('l' + 'r' - r);
            }
        }
        int n;
        Node[] t;

        void build(char[] s) {
            n = s.length;
            t = new Node[n * 4];
            build(0, 0, n - 1, s);
        }
        void build(int v, int tl, int tr, char[] s) {
            if (tl == tr) {
                t[v] = new Node(s[tl]);
                return;
            }
            int tm = (tl + tr) / 2;
            build(v * 2 + 1, tl, tm, s);
            build(v * 2 + 2, tm + 1, tr, s);
            t[v] = merge(t[v * 2 + 1], t[v * 2 + 2]);
        }

        Node merge(Node t1, Node t2) {
            Node t3 = new Node();
            t3.len = t1.len + t2.len;

            if (t1.r >= t2.l) {
                t3.rlPre = t1.rlPre;
                if (t1.rlPre == t1.len)
                    t3.rlPre += t2.rlPre;

                t3.rlSuf = t2.rlSuf;
                if (t2.rlSuf == t2.len)
                    t3.rlSuf += t1.rlSuf;

                t3.rl = Math.max(t1.rl, t2.rl);
                t3.rl = Math.max(t3.rl, t1.rlSuf + t2.rlPre);
                t3.rl = Math.max(t3.rl, t3.rlPre);
                t3.rl = Math.max(t3.rl, t3.rlSuf);
            } else {
                t3.rlPre = t1.rlPre;
                t3.rlSuf = t2.rlSuf;
                t3.rl = Math.max(t1.rl, t2.rl);
            }

            if (t1.r <= t2.l) {
                t3.lrPre = t1.lrPre;
                if (t1.lrPre == t1.len)
                    t3.lrPre += t2.lrPre;

                t3.lrSuf = t2.lrSuf;
                if (t2.lrSuf == t2.len)
                    t3.lrSuf += t1.lrSuf;

                t3.lr = Math.max(t1.lr, t2.lr);
                t3.lr = Math.max(t3.lr, t1.lrSuf + t2.lrPre);
                t3.lr = Math.max(t3.lr, t3.lrPre);
                t3.lr = Math.max(t3.lr, t3.lrSuf);
            } else {
                t3.lrPre = t1.lrPre;
                t3.lrSuf = t2.lrSuf;
                t3.lr = Math.max(t1.lr, t2.lr);
            }

            t3.l = t1.l;
            t3.r = t2.r;

            return t3;
        }

        void push(int v) {
            if (t[v].lazy == 1) {
                t[v * 2 + 1].flip();
                t[v * 2 + 1].lazy ^= 1;
                t[v * 2 + 2].flip();
                t[v * 2 + 2].lazy ^= 1;
                t[v].lazy = 0;
            }
        }

        void upd(int v, int tl, int tr, int l, int r) {
            if (l <= tl && tr <= r) {
                t[v].flip();
                t[v].lazy ^= 1;
                return;
            }
            int tm = (tl + tr) / 2;
            push(v);
            if (r <= tm) {
                upd(v * 2 + 1, tl, tm, l, r);
            } else if (l > tm) {
                upd(v * 2 + 2, tm + 1, tr, l, r);
            } else {
                upd(v * 2 + 1, tl, tm, l, tm);
                upd(v * 2 + 2, tm + 1, tr, tm + 1, r);
            }
            t[v] = merge(t[v * 2 + 1], t[v * 2 + 2]);
        }
        void upd(int l, int r) {
            upd(0, 0, n - 1, l, r);
        }

        Node query(int v, int tl, int tr, int l, int r) {
            if (l <= tl && tr <= r)
                return t[v];
            int tm = (tl + tr) / 2;
            push(v);
            if (r <= tm) {
                return query(v * 2 + 1, tl, tm, l, r);
            } else if (l > tm) {
                return query(v * 2 + 2, tm + 1, tr, l, r);
            } else {
                return merge(query(v * 2 + 1, tl, tm, l, tm),
                        query(v * 2 + 2, tm + 1, tr, tm + 1, r));
            }
        }
        int query(int l, int r) {
            Node res = query(0, 0, n - 1, l, r);
            return res.rl;
        }
    }

    static void solve() {
        int n = in.nextInt();
        int q = in.nextInt();

        char[] s = in.next().toCharArray();

        SegTree st = new SegTree();
        st.build(s);

        for (int qq = 0; qq < q; qq++) {
            int l = in.nextInt() - 1;
            int r = in.nextInt() - 1;
            st.upd(l, r);
            out.println(st.query(l, r));
        }


    }

    public static void main(String[] args) throws FileNotFoundException {
        in = new FastReader(System.in);
//        in = new FastReader(new FileInputStream("sometext.txt"));
        out = new PrintWriter(System.out);
//        out = new PrintWriter(new FileOutputStream("output.txt"));

        int T = 1;
//        T = in.nextInt();
        while (T-- > 0)
            solve();

//        Thread thread = new Thread(null, () -> {
//            solve();
//        }, "Main", 1 << 28);
//        thread.start();
//        try {
//            thread.join();
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }

//        out.flush();
        out.close();
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

        Integer nextInt() {
            return Integer.parseInt(next());
        }

        Long nextLong() {
            return Long.parseLong(next());
        }

        Double nextDouble() {
            return Double.parseDouble(next());
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(nextLine());
            }
            return st.nextToken();
        }

        String nextLine() {
            String s = "";
            try {
                s = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return s;
        }
    }

    static void dbg(Object... args) {
        for (Object arg : args)
            out.print(arg + " ");
        out.println();
    }

}