#include <bits/stdc++.h>
using namespace std;
int fa[200010], cnt;
int find(int x) {
  if (fa[x] == x) {
    return x;
  } else {
    return (fa[x] = find(fa[x]));
  }
}
void merge(int x, int y) {
  int t1 = find(x);
  int t2 = find(y);
  if (t1 != t2) {
    --cnt;
    fa[t1] = t2;
  }
}
int main(void) {
  int n, k;
  while (scanf("%d%d", &n, &k) != EOF) {
    memset(fa, 0, sizeof(fa));
    for (int i = 0; i <= 2 * n + 4; ++i) {
      fa[i] = i;
    }
    cnt = n * 2 + 4;
    for (int i = 1; i <= k; ++i) {
      int u, v;
      char s[5];
      scanf("%d%d%s", &u, &v, s);
      int p = u - 1;
      int q = v - 1;
      u = abs(p - q);
      v = min(2 * n - p - q - 2, p + q);
      if (strcmp(s, "x") == 0) {
        merge(2 * u, 2 * (v + 2));
        merge(2 * u + 1, 2 * (v + 2) + 1);
      } else {
        merge(2 * u, 2 * (v + 2) + 1);
        merge(2 * u + 1, 2 * (v + 2));
      }
    }
    int ans = 1;
    cnt = (cnt - 4) / 2;
    while (cnt > 0) {
      ans = (ans * 2ll) % 1000000007;
      --cnt;
    }
    for (int i = 0; i < n + 2; ++i) {
      if (find(2 * i) == find(2 * i + 1)) {
        ans = 0;
        break;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
