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

public class F {
    static final boolean RUN_TIMING = false;
    static char[] inputBuffer = new char[1 << 20];
    static PushbackReader in = new PushbackReader(new BufferedReader(new InputStreamReader(System.in)), 1 << 20);
    static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    public void go() throws IOException {
        // in = new PushbackReader(new BufferedReader(new FileReader(new File("test.txt"))), 1 << 20);
        // out = new PrintWriter(new FileWriter(new File("output.txt")));
        int n = ipar();
        int q = ipar();
        char[] s = spar().toCharArray();
        SegmentTree tree = new SegmentTree(s);
        // tree.print();
        for (int i = 0; i < q; i++) {
            int l = ipar();
            int r = ipar();
            tree.update(l, r);
            out.println(tree.query(l, r));
            // tree.print();
        }
    }

    public int getMax(int[] arr) {
        int max = arr[0];
        for (int i = 1; i < arr.length; i++) {
            max = Math.max(max, arr[i]);
        }
        return max;
    }

    private class SegmentTree {
        private class Node {
            int len;
            int l, r, nl, nr;
            int hi, nhi;
            char cl, cr;
            boolean flip;
        }

        Node[] tree;
        int n;

        public SegmentTree(char[] s) {
            n = s.length;
            tree = new Node[n*4];
            char[] dir = new char[n+1];
            System.arraycopy(s, 0, dir, 1, n);
            build(1, 1, n, dir);
        }

        private Node createNode(char c) {
            Node node = new Node();
            node.len = 1;
            node.cl = c;
            node.cr = c;
            node.hi = 1;
            node.nhi = 1;
            node.r = 1;
            node.nl = 1;
            node.l = 1;
            node.nr = 1;
            return node;
        }

        private Node combine(Node left, Node right) {
            Node node = new Node();
            node.len = left.len + right.len;
            node.l = left.l;
            node.r = right.r;
            node.hi = Math.max(left.hi, right.hi);
            if (left.cr != '<' || right.cl != '>') {
                node.hi = Math.max(node.hi, left.r + right.l);
                if (left.l == left.len) {
                    node.l += right.l;
                }
                if (right.r == right.len) {
                    node.r += left.r;
                }
            }
            node.nl = left.nl;
            node.nr = right.nr;
            node.nhi = Math.max(left.nhi, right.nhi);
            if (left.cr != '>' || right.cl != '<') {
                node.nhi = Math.max(node.nhi, left.nr + right.nl);
                if (left.nl == left.len) {
                    node.nl += right.nl;
                }
                if (right.nr == right.len) {
                    node.nr += left.nr;
                }
            }
            node.cl = left.cl;
            node.cr = right.cr;
            return node;
        }

        private void build(int v, int tl, int tr, char[] dir) {
            if (tl == tr) {
                tree[v] = createNode(dir[tl]);
                return;
            }
            int tm = (tl+tr)/2;
            build(v*2, tl, tm, dir);
            build(v*2+1, tm+1, tr, dir);
            tree[v] = combine(tree[v*2], tree[v*2+1]);
        }

        private void flipNode(Node node) {
            int temp = node.l;
            node.l = node.nl;
            node.nl = temp;
            temp = node.r;
            node.r = node.nr;
            node.nr = temp;
            temp = node.hi;
            node.hi = node.nhi;
            node.nhi = temp;
            node.cl = node.cl == '>' ? '<' : '>';
            node.cr = node.cr == '>' ? '<' : '>';
        }

        private void push(int v) {
            if (tree[v].flip) {
                tree[v*2].flip ^= true;
                flipNode(tree[v*2]);
                tree[v*2+1].flip ^= true;
                flipNode(tree[v*2+1]);
                tree[v].flip = false;
            }
        }

        private void update(int v, int tl, int tr, int l, int r) {
            if (l > r) {
                return;
            }
            if (l == tl && r == tr) {
                flipNode(tree[v]);
                tree[v].flip ^= true;
                return;
            }
            push(v);
            int tm = (tl+tr)/2;
            update(v*2, tl, tm, l, Math.min(tm, r));
            update(v*2+1, tm+1, tr, Math.max(tm+1, l), r);
            tree[v] = combine(tree[v*2], tree[v*2+1]);
        }

        public void update(int l, int r) {
            update(1, 1, n, l, r);
        }

        private Node query(int v, int tl, int tr, int l, int r) {
            if (l > r) {
                return new Node();
            }
            if (l == tl && r == tr) {
                return tree[v];
            }
            push(v);
            int tm = (tl+tr)/2;
            Node left = query(v*2, tl, tm, l, Math.min(tm, r));
            Node right = query(v*2+1, tm+1, tr, Math.max(tm+1, l), r);
            // out.printf("tl=%d tr=%d l=%d r=%d  %s  %s  ==  %s%n", tl, tr, l, r, left, right, combine(left, right));
            return combine(left, right);
        }

        public int query(int l, int r) {
            Node node = query(1, 1, n, l, r);
            return node.hi;
        }

        private void print(int v, int tl, int tr) {
            if (tl == tr) {
                out.print(tree[v].cr);
                return;
            }
            push(v);
            int tm = (tl+tr)/2;
            print(v*2, tl, tm);
            print(v*2+1, tm+1, tr);
        }

        public void print() {
            print(1, 1, n);
            out.println();
        }
    }

    public int ipar() throws IOException {
        return Integer.parseInt(spar());
    }

    public int[] iapar(int n) throws IOException {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = ipar();
        }
        return arr;
    }

    public long lpar() throws IOException {
        return Long.parseLong(spar());
    }

    public long[] lapar(int n) throws IOException {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = lpar();
        }
        return arr;
    }

    public double dpar() throws IOException {
        return Double.parseDouble(spar());
    }

    public String spar() throws IOException {
        int len = 0;
        int c;
        do {
            c = in.read();
        } while (Character.isWhitespace(c) && c != -1);
        if (c == -1) {
            throw new NoSuchElementException("Reached EOF");
        }
        do {
            inputBuffer[len] = (char)c;
            len++;
            c = in.read();
        } while (!Character.isWhitespace(c) && c != -1);
        while (c != '\n' && Character.isWhitespace(c) && c != -1) {
            c = in.read();
        }
        if (c != -1 && c != '\n') {
            in.unread(c);
        }
        return new String(inputBuffer, 0, len);
    }

    public String linepar() throws IOException {
        int len = 0;
        int c;
        while ((c = in.read()) != '\n' && c != -1) {
            if (c == '\r') {
                continue;
            }
            inputBuffer[len] = (char)c;
            len++;
        }
        return new String(inputBuffer, 0, len);
    }

    public boolean haspar() throws IOException {
        String line = linepar();
        if (line.isEmpty()) {
            return false;
        }
        in.unread('\n');
        in.unread(line.toCharArray());
        return true;
    }

    public static void main(String[] args) throws IOException {
        long time = 0;
        time -= System.nanoTime();
        new F().go();
        time += System.nanoTime();
        if (RUN_TIMING) {
            System.out.printf("%.3f ms%n", time / 1000000.0);
        }
        out.flush();
        in.close();
    }
}