#include <bits/stdc++.h>
const int N = 1e5 + 5, INF = 0x3f3f3f3f, mod = 1e9 + 7;
const double PI = acos(-1), EPS = 1e-9;
using namespace std;
namespace fast_IO {
long long read() {
  long long x = 0;
  char c;
  bool flag = false;
  while ((c = getchar()) == ' ' || c == '\n' || c == '\r')
    ;
  if (c == '-')
    flag = true;
  else
    x = c ^ 48;
  while ((c = getchar()) >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48);
  if (flag) return -x;
  return x;
}
void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) write(x / 10);
  putchar(x % 10 ^ 48);
}
}  // namespace fast_IO
long long dp[105][105];
int p[N], b[N], nt[N], num, w[N];
void add(int x, int y, int z) {
  b[++num] = y, w[num] = z;
  nt[num] = p[x], p[x] = num;
  b[++num] = x, w[num] = -z;
  nt[num] = p[y], p[y] = num;
}
bool judge(int l, int r, int x, int y) {
  for (int e = p[x]; e; e = nt[e]) {
    int k = b[e];
    if (w[e] == 0 && k != y && k != x) return false;
    if (w[e] == 1 && (k < l || k > r)) return false;
    if (w[e] == -1 && ((k >= l && k <= r) || k == y || k == x)) return false;
    if (w[e] == 2 && (k < l || k > r) && k != y && k != x) return false;
    if (w[e] == -2 && k >= l && k <= r) return false;
  }
  for (int e = p[y]; e; e = nt[e]) {
    int k = b[e];
    if (w[e] == 0 && k != x && k != y) return false;
    if (w[e] == 1 && (k < l || k > r)) return false;
    if (w[e] == -1 && ((k >= l && k <= r) || k == x || k == y)) return false;
    if (w[e] == 2 && (k < l || k > r) && k != x && k != y) return false;
    if (w[e] == -2 && k >= l && k <= r) return false;
  }
  return true;
}
int main() {
  int n = fast_IO::read(), m = fast_IO::read();
  for (int i = 1; i <= m; ++i) {
    int x = fast_IO::read(), y;
    char s[3];
    scanf("%s", s);
    y = fast_IO::read();
    if (*s == '=')
      add(x, y, 0);
    else if (*s == '<') {
      if (s[1])
        add(x, y, 2);
      else
        add(x, y, 1);
    } else {
      if (s[1])
        add(x, y, -2);
      else
        add(x, y, -1);
    }
  }
  dp[0][0] = 1;
  for (int k = 1; k <= n; ++k) {
    for (int i = 0; i <= (k - 1) * 2; ++i) {
      int j = (k - 1) * 2 - i;
      if (judge(i + 3, n * 2 - j, i + 1, i + 2)) dp[i + 2][j] += dp[i][j];
      if (judge(i + 2, n * 2 - j - 1, i + 1, n * 2 - j))
        dp[i + 1][j + 1] += dp[i][j];
      if (judge(i + 1, n * 2 - j - 2, n * 2 - j - 1, n * 2 - j))
        dp[i][j + 2] += dp[i][j];
    }
  }
  long long ans = 0;
  for (int i = 0; i <= n * 2; ++i) ans += dp[i][n * 2 - i];
  fast_IO::write(ans / 3);
  return 0;
}
