#include <bits/stdc++.h>
using namespace std;
long long dp[80][80];
int f[80][80], n, k, x, y;
bool flag, w;
char op[10];
void add_1(int x, int y) {
  if ((f[x][y] >= 3 || f[y][x] <= 3) && f[x][y] != -1) {
    flag = true;
    return;
  }
  f[x][y] = 1, f[y][x] = 5;
}
void add_2(int x, int y) {
  if (f[x][y] == 1 || f[x][y] == 5) {
    flag = true;
    return;
  }
  f[x][y] = f[y][x] = 3;
}
void add_3(int x, int y) {
  if (f[x][y] == 1 || f[x][y] == 3) return;
  if (f[x][y] == 4) {
    add_2(x, y);
    return;
  }
  if (f[x][y] == 5) {
    flag = true;
    return;
  }
  f[x][y] = 2, f[y][x] = 4;
}
int main() {
  scanf("%d %d", &n, &k);
  n *= 2;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) f[i][j] = -1;
  for (int i = 1; i <= k; i++) {
    scanf("%d %s %d", &x, op, &y);
    if (op[1] == '=') {
      if (op[0] == '<')
        add_3(x, y);
      else
        add_3(y, x);
    } else {
      if (op[0] == '=')
        add_2(x, y);
      else if (op[0] == '<')
        add_1(x, y);
      else
        add_1(y, x);
    }
  }
  for (int i = 1; i <= n; i++)
    if (f[i][i] == 1 || f[i][i] == 5) flag = true;
  if (flag) {
    printf("0\n");
    return 0;
  }
  for (int i = 1; i <= n; i++) dp[i][i - 1] = dp[i + 1][i] = 1;
  for (int i = 1; i < n; i++)
    if (f[i][i + 1] != 1 && f[i][i + 1] != 5) dp[i][i + 1] = 1;
  for (int l = 4; l <= n; l += 2) {
    for (int i = 1; i + l - 1 <= n; i++) {
      int j = i + l - 1;
      w = true;
      for (int k = i; k <= i + 1; k++)
        for (int l = i + 2; l <= j; l++)
          if (f[k][l] >= 3) w = false;
      if (f[i][i + 1] == 1 || f[i][i + 1] == 5) w = false;
      if (w) dp[i][j] += dp[i + 2][j];
      w = true;
      for (int k = j - 1; k <= j; k++)
        for (int l = i; l <= j - 2; l++)
          if (f[k][l] >= 3) w = false;
      if (f[j - 1][j] == 1 || f[j - 1][j] == 5) w = false;
      if (w) dp[i][j] += dp[i][j - 2];
      w = true;
      for (int k = i + 1; k <= j - 1; k++)
        if (f[i][k] >= 3 || f[j][k] >= 3) w = false;
      if (f[i][j] == 1 || f[i][j] == 5) w = false;
      if (w) dp[i][j] += dp[i + 1][j - 1];
    }
  }
  printf("%lld\n", dp[1][n]);
}
