#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, md = 1e9 + 7;
int n, k;
int fa[N], dis[N];
int qpow(int a, int b) {
  int res = 1;
  for (; b; b >>= 1, a = 1ll * a * a % md)
    if (b & 1) res = 1ll * res * a % md;
  return res;
}
int find(int x) {
  if (fa[x] == x) return x;
  int rt = find(fa[x]);
  dis[x] ^= dis[fa[x]];
  fa[x] = rt;
  return rt;
}
int merge(int x, int y, int c) {
  find(x), find(y);
  c ^= dis[x] ^ dis[y];
  x = find(x), y = find(y);
  if (x == y) {
    if (c) return 0;
    return 1;
  }
  dis[x] = c;
  fa[x] = y;
  return 1;
}
int main() {
  scanf("%d%d", &n, &k);
  int x, y, fg = 1;
  char w;
  for (int i = 0; i < n + 2; i++) fa[i] = i, dis[i] = 0;
  for (int i = 1; i <= k; i++) {
    scanf("%d%d %c", &x, &y, &w);
    x--, y--;
    int l = abs(x - y), r = x + y;
    if (r >= n) r = 2 * (n - 1) - r;
    r += 2;
    int c = w == 'o';
    if (!merge(l, r, c)) {
      fg = 0;
    }
  }
  if (!fg) return printf("0\n"), 0;
  int cnt = 0;
  for (int i = 0; i < n + 2; i++)
    if (fa[i] == i) cnt++;
  printf("%d\n", qpow(2, cnt - 2));
  return 0;
}
