#include <bits/stdc++.h>
using namespace std;
int f[200005], ans, n, m;
long long res = 1;
int get(int x) { return f[x] == x ? x : f[x] = get(f[x]); }
void Union(int x, int y) {
  int p = get(x), q = get(y);
  if (p == q) return;
  ans--;
  f[p] = q;
}
int main() {
  scanf("%d%d", &n, &m);
  ans = 2 * n;
  for (int i = 0; i <= (n + 1) * 2 + 1; ++i) f[i] = i;
  while (m--) {
    int i, j, l, r, k;
    char s[5];
    scanf("%d%d%s", &i, &j, s);
    k = s[0] == 'o';
    i--;
    j--;
    l = abs(i - j);
    r = min(i + j, 2 * n - 2 - i - j);
    l -= 2;
    if (l < 0) l += n + 2;
    Union(l * 2, r * 2 + k);
    Union(l * 2 + 1, r * 2 + k ^ 1);
  }
  for (int i = 0; i <= n + 1; ++i)
    if (get(i * 2 + 1) == get(i * 2)) return puts("0"), 0;
  for (int i = 1; i <= ans / 2; ++i) res = res * 2 % 1000000007;
  printf("%I64d\n", res);
  return 0;
}
