#include <bits/stdc++.h>
using namespace std;
const long long N = 200005;
long long n, k, f[N];
char s[5];
inline long long read() {
  long long ret = 0, ff = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') ff = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    ret = ret * 10 + (ch ^ 48);
    ch = getchar();
  }
  return ret * ff;
}
void write(long long x) {
  if (x < 0) {
    x = -x, putchar('-');
  }
  if (x > 9) write(x / 10);
  putchar(x % 10 + 48);
}
void writeln(long long x) { write(x), puts(""); }
void writesp(long long x) { write(x), putchar(' '); }
long long ksm(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y & 1) res = res * x % 1000000007;
    y >>= 1;
    x = x * x % 1000000007;
  }
  return res;
}
long long find(long long x) { return f[x] == -1 ? x : f[x] = find(f[x]); }
bool merge(long long x, long long y) {
  long long tx = find(x), ty = find(y);
  if (find(x ^ 1) == ty) return 0;
  if (find(y ^ 1) == tx) return 0;
  if (tx != ty) f[tx] = ty;
  return 1;
}
bool check(long long l, long long r, long long t) {
  if (t == 0) {
    return merge(l * 2, r * 2) && merge(l * 2 + 1, r * 2 + 1);
  } else {
    return merge(l * 2, r * 2 + 1) && merge(l * 2 + 1, r * 2);
  }
}
signed main() {
  n = read(), k = read();
  memset(f, -1, sizeof(f));
  for (long long i = 1; i <= k; i++) {
    long long x = read() - 1, y = read() - 1;
    long long l = x - y, r = x + y;
    if (l < 0) l = -l;
    if (r > n - 1) r = (n - 1) * 2 - r;
    scanf("%s", s);
    if (!check(l, r + 2, s[0] == 'x' ? 0 : 1)) {
      write(0);
      return 0;
    }
  }
  long long ans = 0;
  for (long long i = 0; i <= (n + 2) * 2; i++)
    if (find(i) == i) ans++;
  write(ksm(2, ans / 2 - 2));
  return 0;
}
