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 ll, lr, rl, rr;
            //  ><   ><   ><
            int lhi, rhi, hi;
            //  <>    <>    <>
            int nlhi, nrhi, nhi;
            boolean flip;
        }

        Node[] tree;
        int n;

        public SegmentTree(char[] s) {
            n = s.length;
            tree = new Node[n*4];
            int[] dir = new int[n+1];
            for (int i = 0; i < n; i++) {
                dir[i+1] = s[i] == '<' ? -1 : 1;
            }
            build(1, 1, n, dir);
        }

        private Node createNode(int d) {
            Node node = new Node();
            node.len = 1;
            if (d == -1) {
                node.ll = 1;
                node.rl = 1;
            } else {
                node.lr = 1;
                node.rr = 1;
            }
            return node;
        }

        private Node combine(Node left, Node right) {
            Node node = new Node();
            node.len = left.len + right.len;
            node.ll = left.ll + (left.ll == left.len ? right.ll : 0);
            node.lr = left.lr + (left.lr == left.len ? right.lr : 0);
            node.rl = right.rl + (right.rl == right.len ? left.rl : 0);
            node.rr = right.rr + (right.rr == right.len ? left.rr : 0);
            if (left.len == left.lhi) {
                node.lhi = left.lhi + right.ll;
            } else if (left.lhi == 0 && left.lr == left.len && (right.lhi > 0 || right.ll > 0)) {
                node.lhi = left.lr + Math.max(right.lhi, right.ll);
            } else {
                node.lhi = left.lhi;
            }
            if (right.len == right.rhi) {
                node.rhi = right.rhi + left.rr;
            } else if (right.rhi == 0 && right.rl == right.len && (left.rhi > 0 || left.rr > 0)) {
                node.rhi = right.rl + Math.max(left.rhi, left.rr);
            } else {
                node.rhi = right.rhi;
            }
            if (left.len == left.nlhi) {
                node.nlhi = left.nlhi + right.lr;
            } else if (left.nlhi == 0 && left.ll == left.len && (right.nlhi > 0 || right.lr > 0)) {
                node.nlhi = left.ll + Math.max(right.nlhi, right.lr);
            } else {
                node.nlhi = left.nlhi;
            }
            if (right.len == right.nrhi) {
                node.nrhi = right.nrhi + left.rl;
            } else if (right.nrhi == 0 && right.rr == right.len && (left.nrhi > 0 || left.rl > 0)) {
                node.nrhi = right.rr + Math.max(left.nrhi, left.rl);
            } else {
                node.nrhi = right.nrhi;
            }
            node.hi = Math.max(Math.max(left.hi, right.hi), Math.max(node.lhi, node.rhi));
            if (left.rhi > 0) {
                node.hi = Math.max(node.hi, left.rhi + right.ll);
            }
            if (right.lhi > 0) {
                node.hi = Math.max(node.hi, right.lhi + left.rr);
            }
            if (left.rr > 0 && right.ll > 0) {
                node.hi = Math.max(node.hi, left.rr + right.ll);
            }
            node.nhi = Math.max(Math.max(left.nhi, right.nhi), Math.max(node.nlhi, node.nrhi));
            if (left.nrhi > 0) {
                node.nhi = Math.max(node.nhi, left.nrhi + right.lr);
            }
            if (right.nlhi > 0) {
                node.nhi = Math.max(node.nhi, right.nlhi + left.rl);
            }
            if (left.rl > 0 && right.lr > 0) {
                node.nhi = Math.max(node.nhi, left.rl + right.lr);
            }
            return node;
        }

        private void build(int v, int tl, int tr, int[] 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.ll;
            node.ll = node.lr;
            node.lr = temp;
            temp = node.rl;
            node.rl = node.rr;
            node.rr = temp;
            temp = node.lhi;
            node.lhi = node.nlhi;
            node.nlhi = temp;
            temp = node.rhi;
            node.rhi = node.nrhi;
            node.nrhi = temp;
            temp = node.hi;
            node.hi = node.nhi;
            node.nhi = temp;
        }

        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 Math.max(Math.max(node.ll, node.rr), node.hi);
        }

        private void print(int v, int tl, int tr) {
            if (tl == tr) {
                out.print(tree[v].ll == 0 ? '>' : '<');
                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();
    }
}