#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const int MOD = 1000000007;
int n, m;
int fa[N << 1];
int getf(int v) {
  if (v == fa[v]) return v;
  fa[v] = getf(fa[v]);
  return fa[v];
}
void merge(int u, int v) {
  int f1 = getf(u), f2 = getf(v);
  if (f1 != f2) fa[f2] = f1;
  return;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i <= (n + 1) * 2 + 1; i++) fa[i] = i;
  for (int i = 1; i <= m; i++) {
    int x, y;
    char c;
    scanf("%d %d %c", &x, &y, &c);
    int l = max(x - y - 1 + 2, y - x + 1) - 1,
        r = min(x + y - 1, 2 * n - x - y + 1) + 1;
    if (c == 'x') {
      merge(l, r);
      merge(l + n + 2, r + n + 2);
    } else if (c == 'o') {
      merge(l, r + n + 2);
      merge(l + n + 2, r);
    }
  }
  for (int i = 0; i <= n + 1; i++)
    if (getf(i) == getf(i + n + 2)) {
      printf("0");
      return 0;
    }
  int cnt = 0;
  for (int i = 0; i <= (n + 1) * 2 + 1; i++)
    if (getf(i) == i) cnt++;
  cnt = (cnt - 4) / 2;
  long long ans = 1;
  for (int i = 1; i <= cnt; i++) ans = ans * 2 % MOD;
  printf("%lld", ans);
  return 0;
}
