#include <bits/stdc++.h>
using namespace std;
inline char gc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline long long read() {
  long long x = 0;
  char ch = getchar();
  bool positive = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') positive = 0;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return positive ? x : -x;
}
inline void write(long long x) {
  if (x < 0) {
    x = -x;
    putchar('-');
  }
  if (x >= 10) write(x / 10);
  putchar('0' + x % 10);
}
inline void writeln(long long x) {
  write(x);
  puts("");
}
inline void writep(long long x) {
  write(x);
  putchar(' ');
}
inline unsigned long long rnd() {
  return ((unsigned long long)rand() << 30 ^ rand()) << 4 | rand() % 4;
}
const int N = 2e5 + 5, mo = 1e9 + 7;
int fa[N];
int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
void merge(int x, int y) {
  int u = find(x), v = find(y);
  if (u != v) fa[u] = v;
}
int main() {
  int n = read(), m = read();
  for (int i = (int)(1); i <= (int)(2 * n + 3); i++) fa[i] = i;
  for (int i = (int)(1); i <= (int)(m); i++) {
    int x = read(), y = read();
    char s[4];
    scanf("%s", s);
    x -= y;
    int l = abs(x), r = min(x + 2 * y, 2 * n - x - 2 * y + 2);
    if (s[0] == 'x')
      merge(2 * r, 2 * l), merge(2 * r + 1, 2 * l + 1);
    else
      merge(2 * r, 2 * l + 1), merge(2 * r + 1, 2 * l);
  }
  for (int i = (int)(0); i <= (int)(n + 1); i++)
    if (find(i * 2) == find(2 * i + 1)) {
      return puts("0"), 0;
    }
  int cnt = 0;
  for (int i = (int)(0); i <= (int)(2 * n + 3); i++) cnt += (find(i) == i);
  long long ans = 1;
  for (int i = (int)(1); i <= (int)(cnt / 2 - 2); i++)
    ans = (long long)ans * 2 % mo;
  cout << ans;
}
