#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300005, Mo = 1000000007;
int N, K, M, Fa[MAXN], tot;
int get(int a) { return Fa[a] == a ? a : Fa[a] = get(Fa[a]); }
void link(int a, int b) {
  int x = get(a), y = get(b);
  if (x != y) tot--;
  Fa[x] = y;
}
int main() {
  scanf("%d%d", &N, &K);
  for (int i = 0; i <= 2 * N + 3; i++) Fa[i] = i;
  tot = N * 2;
  int S = N + 2;
  for (int i = 1; i <= K; i++) {
    int x, y;
    char c;
    scanf("%d%d", &x, &y);
    x--, y--;
    while (c = getchar(), c != 'x' && c != 'o')
      ;
    int p = (x + y), bz = c == 'o';
    int l = abs(x - y), r = min(p, 2 * (N - 1) - x - y);
    r += 2;
    link(l * 2, r * 2 + bz), link(l * 2 + 1, r * 2 + (bz ^ 1));
  }
  bool none = 0;
  for (int i = 0; i <= N + 1; i++)
    if (get(i * 2 + 1) == get(i * 2)) {
      none = 1;
      break;
    }
  if (none)
    printf("0\n");
  else {
    int Tmp = 1;
    for (int i = 1; i <= tot / 2; i++) Tmp = Tmp * 2 % Mo;
    printf("%d\n", Tmp);
  }
}
