#include <bits/stdc++.h>
using namespace std;
const int maxn(105);
long long f[maxn][maxn], n, m, ans, k;
vector<pair<int, int> > cd[maxn];
string s;
inline bool Check(int yl, int yr, int ql, int qr, int p1, int p2) {
  for (int i = 0, l = cd[p1].size(); i < l; ++i) {
    if (cd[p1][i].first == 1 &&
        (cd[p1][i].second < yl || cd[p1][i].second > yr))
      return 0;
    if (cd[p1][i].first == 2 && cd[p1][i].second >= ql &&
        cd[p1][i].second <= qr)
      return 0;
    if (cd[p1][i].first == 3 &&
        (cd[p1][i].second < ql || cd[p1][i].second > qr))
      return 0;
    if (cd[p1][i].first == 4 && cd[p1][i].second > yl && cd[p1][i].second < yr)
      return 0;
    if (cd[p1][i].first == 5 && p2 != cd[p1][i].second &&
        p1 != cd[p1][i].second)
      return 0;
  }
  for (int i = 0, l = cd[p2].size(); i < l; ++i) {
    if (cd[p2][i].first == 1 &&
        (cd[p2][i].second < yl || cd[p2][i].second > yr))
      return 0;
    if (cd[p2][i].first == 2 && cd[p2][i].second >= ql &&
        cd[p2][i].second <= qr)
      return 0;
    if (cd[p2][i].first == 3 &&
        (cd[p2][i].second < ql || cd[p2][i].second > qr))
      return 0;
    if (cd[p2][i].first == 4 && cd[p2][i].second > yl && cd[p2][i].second < yr)
      return 0;
    if (cd[p2][i].first == 5 && p1 != cd[p2][i].second &&
        p2 != cd[p2][i].second)
      return 0;
  }
  return 1;
}
int main() {
  ios ::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1, a, b; i <= m; ++i) {
    cin >> a >> s >> b;
    if (a == b && (s == ">" || s == "<")) return puts("0"), 0;
    if (s[0] == '>') swap(a, b), s[0] = '<';
    if (s == "=")
      cd[a].push_back(make_pair(5, b)), cd[b].push_back(make_pair(5, a));
    else if (s == "<")
      cd[a].push_back(make_pair(1, b)), cd[b].push_back(make_pair(2, a));
    else
      cd[a].push_back(make_pair(3, b)), cd[b].push_back(make_pair(4, a));
  }
  k = n << 1, f[0][k + 1] = 1;
  for (int i = n; i > 1; --i)
    for (int l = k - i - i + 2; ~l; --l) {
      int r = l + i + i - 1;
      if (l > 1 && Check(l + 1, r - 1, l - 1, r - 1, l - 1, l))
        f[l][r] += f[l - 2][r];
      if (r + 1 <= k && Check(l + 1, r - 1, l + 1, r + 1, r, r + 1))
        f[l][r] += f[l][r + 2];
      if (l && r <= k && Check(l + 1, r - 1, l, r, l, r))
        f[l][r] += f[l - 1][r + 1];
    }
  for (int i = k - 2; ~i; --i)
    if (Check(i + 2, i + 1, i + 1, i + 2, i + 1, i + 2)) ans += f[i][i + 3];
  cout << ans << endl;
  return 0;
}
