#include <bits/stdc++.h>
using namespace std;
int n, m, pa[200005], cnt;
int find_pa(int a) {
  if (pa[a] == -1) return a;
  return pa[a] = find_pa(pa[a]);
}
void addedge(int a, int b) {
  int pa1, pa2;
  pa2 = find_pa(a);
  pa1 = find_pa(b);
  if (pa1 != pa2) {
    cnt--;
    pa[pa1] = pa2;
  }
}
long long pow(int a, int b) {
  if (b == 0) return 1;
  if (b == 1) return a;
  long long s = pow(a, b >> 1);
  if (b & 1) {
    return (s * s * a) % 1000000007;
  } else
    return (s * s) % 1000000007;
}
int main() {
  memset(pa, -1, sizeof(pa));
  int i, a, b, minx, maxx;
  char s[10] = {
      0,
  };
  scanf("%d %d", &n, &m);
  cnt = n * 2 + 4;
  while (m--) {
    scanf("%d %d %s", &a, &b, s);
    a--;
    b--;
    minx = abs(b - a);
    maxx = ((2 * n - a - b - 2 < a + b) ? 2 * n - a - b - 2 : a + b);
    if (s[0] == 'o') {
      addedge(minx * 2, (maxx + 2) * 2 + 1);
      addedge(minx * 2 + 1, (maxx + 2) * 2);
    } else {
      addedge(minx * 2, (maxx + 2) * 2);
      addedge(minx * 2 + 1, (maxx + 2) * 2 + 1);
    }
  }
  for (i = 0; i < n + 2; i++) {
    if (find_pa(i * 2) == find_pa(i * 2 + 1)) {
      printf("0");
      return 0;
    }
  }
  printf("%I64d\n", pow(2, (cnt - 4) / 2));
  return 0;
}
