1371_F. Raging Thunder_5183
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. 
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author xwchen
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskF solver = new TaskF();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskF {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int q = in.nextInt();
            char[] s = in.nextLine().toCharArray();
            SegmentTree st = new SegmentTree(n);
            st.build(s);
            while (q-- > 0) {
                int l = in.nextInt();
                int r = in.nextInt();
                st.update(l, r, 1);
                out.println(st.query(l, r));
            }
        }

    }

    static class SegmentTree {
        int n;
        Node[] nodes = null;
        Node[] rNodes = null;
        char[] a = null;
        int[] rev = null;

        public SegmentTree(int n) {
            int m = n * 4;
            this.n = n;
            nodes = new Node[m];
            rNodes = new Node[m];
            rev = new int[m];
            for (int i = 0; i < m; ++i) {
                nodes[i] = new Node();
                rNodes[i] = new Node();
            }
        }

        public void build(char[] a) {
            this.a = a;
            build(1, 1, n, a);
        }

        public void build(int root, int nodeLeft, int nodeRight, char[] a) {
            nodes[root].left = nodeLeft;
            nodes[root].right = nodeRight;
            rNodes[root].left = nodeLeft;
            rNodes[root].right = nodeRight;
            nodes[root].lazy_value = rNodes[root].lazy_value = 0;
//      System.out.println(String.format("node[%d] [%d,%d]", cur, left[cur], right[cur]));
            if (nodeLeft == nodeRight) {
                //System.out.println(" L:"+cur.left);
                if (a[nodeLeft - 1] == '<') {
                    rNodes[root].leftRight = nodes[root].leftLeft = 1;
                    rNodes[root].leftLeft = nodes[root].leftRight = 0;
                    rNodes[root].rightRight = nodes[root].rightLeft = 1;
                    rNodes[root].rightLeft = nodes[root].rightRight = 0;
                    rNodes[root].maxValue = nodes[root].maxValue = 1;
                } else {
                    rNodes[root].leftRight = nodes[root].leftLeft = 0;
                    rNodes[root].leftLeft = nodes[root].leftRight = 1;
                    rNodes[root].rightRight = nodes[root].rightLeft = 0;
                    rNodes[root].rightLeft = nodes[root].rightRight = 1;
                    rNodes[root].maxValue = nodes[root].maxValue = 1;
                }
//          System.out.println(String.format("node[%d] [%d,%d] sum =%d", cur, left[cur], right[cur], sum[cur]));
            } else {
                int leftChild = root * 2;
                int rightChild = root * 2 + 1;
                int mid = (nodeLeft + nodeRight) / 2;
                build(leftChild, nodeLeft, mid, a);
                build(rightChild, mid + 1, nodeRight, a);
                pull_up(nodes[root], nodes[leftChild], nodes[rightChild]);
                pull_up(rNodes[root], rNodes[leftChild], rNodes[rightChild]);
                //System.out.println(String.format("node[%d] [%d,%d] leftLeft = %d leftRight = %d rightLeft = %d rightRight = %d %s", root, nodeLeft, nodeRight, nodes[root].leftLeft, nodes[root].leftRight, nodes[root].rightLeft, nodes[root].rightRight, subString(a, nodeLeft, nodeRight + 1)));
            }
        }

        void pull_up(Node cur, Node left, Node right) {
            //int pair = Math.min(left.rightBracket, right.leftBracket);
            //cur.val = Math.max(left.val, right.val);
            cur.maxValue = Math.max(left.maxValue, right.maxValue);
            cur.leftRight = left.leftRight;
            if (left.leftLeft > 0) {
                cur.leftLeft = left.leftLeft;
                if (left.leftLeft + left.leftRight == left.right - left.left + 1) {
                    if (right.leftRight == 0) {
                        cur.leftLeft += right.leftLeft;
                    }
                }
            } else {
                cur.leftRight += right.leftRight;
                cur.leftLeft = right.leftLeft;
            }
            cur.maxValue = Math.max(cur.maxValue, cur.leftRight + cur.leftLeft);

            cur.rightLeft = right.rightLeft;
            if (right.rightRight > 0) {
                cur.rightRight = right.rightRight;
                if (right.rightLeft + right.rightRight == right.right - right.left + 1) {
                    if (left.rightLeft == 0) {
                        cur.rightRight += left.rightRight;
                    }
                }
            } else {
                cur.rightLeft += left.rightLeft;
                cur.rightRight = left.rightRight;
            }
            cur.maxValue = Math.max(cur.maxValue, cur.rightRight + cur.rightLeft);
            if (left.rightLeft == 0) {
                cur.maxValue = Math.max(cur.maxValue, left.rightRight + right.leftRight + right.leftLeft);
            }
            if (right.leftRight == 0) {
                cur.maxValue = Math.max(cur.maxValue, right.leftLeft + left.rightLeft + left.rightRight);
            }
            //cur.leftBracket = left.leftBracket + right.leftBracket - pair;
            //cur.rightBracket = right.rightBracket + left.rightBracket - pair;
        }

        void push_down(int root) {
            if (rev[root] == 1) {
                if (nodes[root].left < nodes[root].right) {
                    flip(root * 2);
                    flip(root * 2 + 1);
                }
                rev[root] = 0;
            }
        }

        void flip(int root) {
            rev[root] ^= 1;
            Node tmp = nodes[root];
            nodes[root] = rNodes[root];
            rNodes[root] = tmp;
        }

        public void update(int queryLeft, int queryRight, int value) {
            //System.out.println(String.format("%d->%d += %d", from, to, value));
            update(1, 1, n, queryLeft, queryRight, value);
        }

        public void update(int root, int nodeLeft, int nodeRight, int queryLeft, int queryRight, int value) {
            //System.out.println(String.format("enter node[%d] range[%d,%d] query[%d,%d]", root, nodeLeft, nodeRight, queryLeft, queryRight));
            //System.out.println(String.format("enter node[%d] lazy = %d [%d,%d] leftLeft = %d leftRight = %d rightLeft = %d rightRight = %d %s", root, nodes[root].lazy_value, nodeLeft, nodeRight, nodes[root].leftLeft, nodes[root].leftRight, nodes[root].rightLeft, nodes[root].rightRight, subString(a, nodeLeft, nodeRight + 1)));

            if (queryLeft <= nodeLeft && nodeRight <= queryRight) {
                flip(root);
                //System.out.println(String.format("exit node[%d] lazy = %d [%d,%d] leftLeft = %d leftRight = %d rightLeft = %d rightRight = %d %s", root, nodes[root].lazy_value, nodeLeft, nodeRight, nodes[root].leftLeft, nodes[root].leftRight, nodes[root].rightLeft, nodes[root].rightRight, subString(a, nodeLeft, nodeRight + 1)));
            } else {
                push_down(root);
                int leftChild = root * 2;
                int rightChild = root * 2 + 1;
                int mid = (nodeLeft + nodeRight) / 2;
                if (queryLeft <= mid) {
                    update(leftChild, nodeLeft, mid, queryLeft, queryRight, value);
                }
                if (queryRight >= mid + 1) {
                    update(rightChild, mid + 1, nodeRight, queryLeft, queryRight, value);
                }
                pull_up(nodes[root], nodes[leftChild], nodes[rightChild]);
                pull_up(rNodes[root], rNodes[leftChild], rNodes[rightChild]);
                //System.out.println(String.format("exit node[%d] lazy = %d [%d,%d] leftLeft = %d leftRight = %d rightLeft = %d rightRight = %d %s", root, nodes[root].lazy_value, nodeLeft, nodeRight, nodes[root].leftLeft, nodes[root].leftRight, nodes[root].rightLeft, nodes[root].rightRight, subString(a, nodeLeft, nodeRight + 1)));

                //System.out.println(String.format("after node [%d,%d] max =%d  add %d", cur.left, cur.right, cur.val, value));
            }
        }

        public int query(int queryLeft, int queryRight) {
            Node qNode = query(1, 1, n, queryLeft, queryRight);
            return qNode.maxValue;
        }

        public Node query(int root, int nodeLeft, int nodeRight, int queryLeft, int queryRight) {
//        System.out.println(String.format("node[%d] [%d,%d] sum =%d", cur, left[cur], right[cur], sum[cur]));

            if (queryLeft <= nodeLeft && nodeRight <= queryRight) {
                return nodes[root];
            } else {
                push_down(root);
                int leftChild = root * 2;
                int rightChild = root * 2 + 1;
                int mid = (nodeLeft + nodeRight) / 2;
                if (queryRight <= mid) {
                    return query(leftChild, nodeLeft, mid, queryLeft, queryRight);
                }
                if (queryLeft >= mid + 1) {
                    return query(rightChild, mid + 1, nodeRight, queryLeft, queryRight);
                }
                Node ql = query(leftChild, nodeLeft, mid, queryLeft, queryRight);
                Node qr = query(rightChild, mid + 1, nodeRight, queryLeft, queryRight);
                Node qNode = new Node();
                pull_up(qNode, ql, qr);
                return qNode;
            }
        }

        class Node {
            int left;
            int right;
            int leftLeft;
            int leftRight;
            int rightLeft;
            int rightRight;
            int maxValue;
            int lazy_value;

        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer = new StringTokenizer("");

        public InputReader(InputStream inputStream) {
            this.reader = new BufferedReader(
                    new InputStreamReader(inputStream));
        }

        public String next() {
            while (!tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            String ret = "";
            try {
                ret = reader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return ret;
        }

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

    }
}

