#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7, N = 1e5 + 10;
int n, k, f[N << 1], ans;
int bcj(int x) { return f[x] == x ? x : f[x] = bcj(f[x]); }
void add(int l, int r, int v) {
  int l1 = l << 1, l2 = l << 1 | 1;
  int r1 = r << 1, r2 = r << 1 | 1;
  if (v == 0) {
    if (bcj(l1) == bcj(r2) || bcj(l2) == bcj(r1)) printf("0"), exit(0);
    f[bcj(l1)] = bcj(r1);
    f[bcj(l2)] = bcj(r2);
  } else {
    if (bcj(l1) == bcj(r1) || bcj(l2) == bcj(r2)) printf("0"), exit(0);
    f[bcj(l1)] = bcj(r2);
    f[bcj(l2)] = bcj(r1);
  }
  return;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= (n + 2) * 2 + 1; i++) f[i] = i;
  for (int i = 1; i <= k; i++) {
    int x, y;
    char s[5];
    scanf("%d%d%s", &x, &y, s + 1);
    x--, y--;
    int l = max(x - y, y - x), r = min(x + y, 2 * (n - 1) - (x + y));
    add(l, r + 2, s[1] == 'x' ? 0 : 1);
  }
  for (int i = 0; i <= (n + 2) * 2 + 1; i++)
    if (bcj(i) == i) ans++;
  int sum = 1;
  for (int i = 1; i <= ans / 2 - 3; i++) sum = 2ll * sum % (int)(1e9 + 7);
  printf("%d", sum);
  return 0;
}
