#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "[";
  for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++i) {
    if (i != v.begin()) os << ", ";
    os << *i;
  }
  os << "]";
  return os;
}
vector<vector<int> > G_same[2];
vector<vector<int> > G_opposite[2];
vector<int> F[2];
bool DFS(int p, int x) {
  for (__typeof((G_same[p][x]).begin()) i = (G_same[p][x]).begin();
       i != (G_same[p][x]).end(); ++i)
    if (F[p][*i] == 0) {
      F[p][*i] = F[p][x];
      DFS(p, *i);
    } else if (F[p][*i] != F[p][x]) {
      return false;
    }
  for (__typeof((G_opposite[p][x]).begin()) i = (G_opposite[p][x]).begin();
       i != (G_opposite[p][x]).end(); ++i)
    if (F[p][*i] == 0) {
      F[p][*i] = 3 - F[p][x];
      DFS(p, *i);
    } else if (F[p][*i] == F[p][x]) {
      return false;
    }
  return true;
}
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int p = 0; p < (int)(2); ++p) {
    G_same[p].resize(n + 2);
    G_opposite[p].resize(n + 2);
  }
  for (int i = 0; i < (int)(k); ++i) {
    int a, b;
    char c;
    scanf("%d%d %c", &a, &b, &c);
    --a, --b;
    int u = max(a - b, b - a);
    int v = min(a + b, 2 * (n - 1) - a - b);
    assert(0 <= u && u <= v && v < n);
    v += 2;
    int p = (a + b) % 2;
    if (c == 'x') {
      G_same[p][u].push_back(v);
      G_same[p][v].push_back(u);
    } else {
      G_opposite[p][u].push_back(v);
      G_opposite[p][v].push_back(u);
    }
  }
  int components[2] = {0, 0};
  for (int p = 0; p < (int)(2); ++p) {
    F[p].resize(n + 2, 0);
    for (int i = 0; i < (int)(n + 2); ++i)
      if (i % 2 == p && F[p][i] == 0) {
        ++components[p];
        F[p][i] = 1;
        if (!DFS(p, i)) {
          printf("0\n");
          return 0;
        }
      }
  }
  int res = 1;
  const int MOD = 1000000007;
  for (int p = 0; p < (int)(2); ++p)
    for (int i = 0; i < (int)(components[p] - 1); ++i) res = (res * 2) % MOD;
  printf("%d\n", res);
}
