#include <bits/stdc++.h>
using namespace std;
int n, m, f[100005], v[100005], ff[100005], vv[100005], hc[100005];
int gf(int x) {
  if (f[x] == x) return x;
  int g = gf(f[x]);
  v[x] ^= v[f[x]];
  f[x] = g;
  return g;
}
int gff(int x) {
  if (ff[x] == x) return x;
  int g = gff(ff[x]);
  vv[x] ^= vv[ff[x]];
  ff[x] = g;
  return g;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i <= n; i++) f[i] = ff[i] = i, v[i] = vv[i] = 0;
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    int l = abs(x - y) + 1, r = min(x + y - 1, 2 * n + 1 - x - y), jb;
    char ch = getchar();
    while (!(ch == 'x' || ch == 'o')) ch = getchar();
    if (ch == 'o')
      jb = 1;
    else
      jb = 0;
    if ((x + y) & 1) {
      l /= 2;
      r /= 2;
      l--;
      int ll = gf(l), rr = gf(r);
      if (ll == rr) {
        if ((v[l] ^ v[r]) != jb) {
          printf("0");
          return 0;
        }
      }
      v[ll] = v[l] ^ v[r] ^ jb;
      f[ll] = rr;
    } else {
      l = (l + 1) / 2;
      r = (r + 1) / 2;
      l--;
      int ll = gff(l), rr = gff(r);
      if (ll == rr) {
        if ((vv[l] ^ vv[r]) != jb) {
          printf("0");
          return 0;
        }
      }
      vv[ll] = vv[l] ^ vv[r] ^ jb;
      ff[ll] = rr;
    }
  }
  int cnt = -2;
  for (int i = 0; i <= n / 2; i++)
    if (!hc[gf(i)]) {
      hc[gf(i)] = 1;
      cnt++;
    }
  memset(hc, 0, sizeof(hc));
  for (int i = 0; i <= (n + 1) / 2; i++)
    if (!hc[gff(i)]) {
      hc[gff(i)] = 1;
      cnt++;
    }
  int ans = 1;
  for (; cnt--;) ans = ans * 2 % 1000000007;
  printf("%d", ans);
}
