Problem: King of Berland Berl IV has recently died. Hail Berl V! As a sign of the highest achievements of the deceased king the new king decided to build a mausoleum with Berl IV's body on the main square of the capital.

The mausoleum will be constructed from 2n blocks, each of them has the shape of a cuboid. Each block has the bottom base of a 1 × 1 meter square. Among the blocks, exactly two of them have the height of one meter, exactly two have the height of two meters, ..., exactly two have the height of n meters.

The blocks are arranged in a row without spacing one after the other. Of course, not every arrangement of blocks has the form of a mausoleum. In order to make the given arrangement in the form of the mausoleum, it is necessary that when you pass along the mausoleum, from one end to the other, the heights of the blocks first were non-decreasing (i.e., increasing or remained the same), and then — non-increasing (decrease or remained unchanged). It is possible that any of these two areas will be omitted. For example, the following sequences of block height meet this requirement:

  * [1, 2, 2, 3, 4, 4, 3, 1]; 
  * [1, 1]; 
  * [2, 2, 1, 1]; 
  * [1, 2, 3, 3, 2, 1]. 



Suddenly, k more requirements appeared. Each of the requirements has the form: "h[xi] signi h[yi]", where h[t] is the height of the t-th block, and a signi is one of the five possible signs: '=' (equals), '<' (less than), '>' (more than), '<=' (less than or equals), '>=' (more than or equals). Thus, each of the k additional requirements is given by a pair of indexes xi, yi (1 ≤ xi, yi ≤ 2n) and sign signi.

Find the number of possible ways to rearrange the blocks so that both the requirement about the shape of the mausoleum (see paragraph 3) and the k additional requirements were met.

Input

The first line of the input contains integers n and k (1 ≤ n ≤ 35, 0 ≤ k ≤ 100) — the number of pairs of blocks and the number of additional requirements.

Next k lines contain listed additional requirements, one per line in the format "xi signi yi" (1 ≤ xi, yi ≤ 2n), and the sign is on of the list of the five possible signs.

Output

Print the sought number of ways.

Examples

Input

3 0


Output

9


Input

3 1
2 &gt; 3


Output

1


Input

4 1
3 = 6


Output

3

Solution (in JAVA):

Solution:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.List;

/**
 * Created by hama_du on 15/08/10.
 */
public class F {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        n = in.nextInt();
        int k = in.nextInt();
        cds = new List[2*n];
        for (int i = 0; i < 2*n ; i++) {
            cds[i] = new ArrayList<>();
        }
        for (int i = 0; i < k ; i++) {
            int a = in.nextInt()-1;
            String tp = in.nextToken();
            int b = in.nextInt()-1;
            Condition cd = new Condition(a, tp, b);
            Condition cdRev = cd.rev();
            cds[cd.a].add(cd);
            cds[cdRev.a].add(cdRev);
        }
        memo = new long[n][2*n][2*n];
        for (int i = 0 ; i < n; i++) {
            for (int j = 0; j < 2*n; j++) {
                Arrays.fill(memo[i][j], -1);
            }
        }

        out.println(dfs(0, 0, 2*n-1));
        out.flush();
    }

    // 123456
    //

    static int n;
    static List<Condition>[] cds;
    static long[][][] memo;

    static long dfs(int idx, int fr, int to) {
        if (idx == n) {
            return 1;
        }
        if (memo[idx][fr][to] != -1) {
            return memo[idx][fr][to];
        }

        int[][] next = new int[3][];
        int[][] zero = new int[3][];
        int[][] lessEqualMore = new int[3][2*n];
        for (int i = 0; i < 3 ; i++) {
            Arrays.fill(lessEqualMore[i], -1);
        }
        for (int i = 0; i < 3; i++) {
            for (int j = fr ; j <= to; j++) {
                lessEqualMore[i][j] = 1;
            }
        }

        // 1-1-[]
        next[0] = new int[]{fr+2, to};
        zero[0] = new int[]{fr, fr+1};

        // []-1-1
        next[1] = new int[]{fr, to-2};
        zero[1] = new int[]{to, to-1};

        // 1-[]-1
        next[2] = new int[]{fr+1, to-1};
        zero[2] = new int[]{fr, to};

        int upk = (fr+1 == to) ? 1 : 3;
        long ret = 0;
        for (int k = 0; k < upk ; k++) {
            boolean can = true;
            List<Condition> cond = new ArrayList<>();
            for (int i = 0; i <= 1; i++) {
                cond.addAll(cds[zero[k][i]]);
                lessEqualMore[k][zero[k][i]] = 0;
            }
            for (Condition cd : cond) {
                if (!cd.match(lessEqualMore[k][cd.b])) {
                    can = false;
                    break;
                }
            }
            if (can) {
                ret += dfs(idx+1, next[k][0], next[k][1]);
            }
        }
        memo[idx][fr][to] = ret;
        return ret;
    }

    // [fr,to]
    static class Condition  {
        int a;
        String type;
        int b;

        Condition(int a, String t, int b) {
            this.a = a;
            this.type = t;
            this.b = b;
        }

        Condition rev() {
            return new Condition(b, revType(type), a);
        }


        // less : -1
        // eq : 0
        // more : 1
        boolean match(int lessEqMore) {
            if (type.equals("=")) {
                return lessEqMore == 0;
            } else if (type.equals("<")) {
                return lessEqMore == 1;
            } else if (type.equals(">")) {
                return lessEqMore == -1;
            } else if (type.equals("<=")) {
                return lessEqMore != -1;
            } else if (type.equals(">=")) {
                return lessEqMore != 1;
            } else {
                throw new RuntimeException();
            }
        }

        static String revType(String type) {
            if (type.equals("=")) {
                return type;
            } else if (type.equals("<")) {
                return ">";
            } else if (type.equals(">")) {
                return "<";
            } else if (type.equals("<=")) {
                return ">=";
            } else if (type.equals(">=")) {
                return "<=";
            } else {
                throw new RuntimeException();
            }
        }
    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private int next() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public char nextChar() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            if ('a' <= c && c <= 'z') {
                return (char) c;
            }
            if ('A' <= c && c <= 'Z') {
                return (char) c;
            }
            throw new InputMismatchException();
        }

        public String nextToken() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            StringBuilder res = new StringBuilder();
            do {
                res.append((char) c);
                c = next();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public int nextInt() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = next();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long nextLong() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            long sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = next();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }

    static void debug(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }
}