#include <bits/stdc++.h>
using namespace std;
int n, k, tot;
long long Dp[500][500];
vector<int> leq[500], dey[500], lar[500];
int gi() {
  int x = 0, k = 1;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') k = -1, c = getchar();
  while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0', c = getchar();
  return x * k;
}
void init() {
  int u, v;
  char s[10];
  scanf("%d%s%d", &u, s, &v);
  if (s[0] == '=') {
    dey[u].push_back(v);
    dey[v].push_back(u);
    return;
  }
  if (s[0] == '<') swap(u, v);
  if (s[1] == '=') {
    leq[u].push_back(v);
    return;
  } else
    lar[u].push_back(v);
}
int yes(int a, int b, int l, int r) {
  for (int i = 0; i < lar[a].size(); ++i)
    if ((lar[a][i] >= l && lar[a][i] <= r) || lar[a][i] == b) return 0;
  for (int i = 0; i < leq[a].size(); ++i)
    if (leq[a][i] >= l && leq[a][i] <= r) return 0;
  for (int i = 0; i < dey[a].size(); ++i)
    if (dey[a][i] >= l && dey[a][i] <= r) return 0;
  return 1;
}
int check(int a, int b, int l, int r) {
  return yes(a, b, l, r) && yes(b, a, l, r);
}
int main() {
  n = gi(), k = gi(), tot = n * 2;
  for (int i = 1; i <= k; ++i) init();
  for (int l = 1, r = l + 1; r <= tot; ++l, ++r)
    if (check(l, r, 0, 0)) Dp[l][r] = 1;
  for (int len = 2; len <= tot; len += 2)
    for (int l = 1, r = len + l - 1; r <= tot; ++l, ++r) {
      if (check(l, l + 1, l + 2, r)) Dp[l][r] += Dp[l + 2][r];
      if (check(r - 1, r, l, r - 2)) Dp[l][r] += Dp[l][r - 2];
      if (check(l, r, l + 1, r - 1)) Dp[l][r] += Dp[l + 1][r - 1];
    }
  printf("%lld", Dp[1][tot]);
  return 0;
}
