#include <bits/stdc++.h>
using namespace std;
const int N = 200005, M = 1e9 + 7;
int tot, n, m, f[N], x, y;
char s[5];
int find(int x) {
  if (f[x] == x) return x;
  return f[x] = find(f[x]);
}
void merge(int x, int y) {
  int fx = find(x), fy = find(y);
  if (fx != fy) f[fy] = fx, tot--;
}
int main() {
  scanf("%d%d", &n, &m);
  tot = n << 1;
  for (int i = 0; i <= 2 * n + 3; i++) f[i] = i;
  while (m--) {
    scanf("%d%d%s", &x, &y, s);
    int k = s[0] == 'o';
    x--, y--;
    int l = abs(x - y), r = min(x + y, 2 * n - 2 - x - y) + 2;
    merge(l * 2, r * 2 + k), merge(l * 2 + 1, r * 2 + (k ^ 1));
  }
  for (int i = 0; i <= n + 1; i++)
    if (find(i * 2) == find(i * 2 + 1)) {
      puts("0");
      return 0;
    }
  int ans = 1;
  for (int i = 1; i <= tot / 2; i++) ans = ans * 2 % M;
  printf("%d\n", ans);
  return 0;
}
