#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool GetMin(T &a, T b) {
  return ((a <= b) ? false : (a = b, true));
}
template <typename T>
bool GetMax(T &a, T b) {
  return ((a >= b) ? false : (a = b, true));
}
const int N = 133333;
const int MOD = 1e9 + 7;
int n, ki, fa[N], w[N];
int Find(int x) {
  if (fa[x]) {
    int t = Find(fa[x]);
    w[x] ^= w[fa[x]];
    fa[x] = t;
    return t;
  } else
    return x;
}
void Merge(int x, int y, int z) {
  int tx = Find(x), ty = Find(y);
  z ^= w[x] ^ w[y];
  if (tx == ty) {
    if (z) {
      puts("0");
      exit(0);
    }
  } else {
    if (tx == n + 1) swap(tx, ty);
    fa[tx] = ty;
    w[tx] = z;
  }
}
int main() {
  scanf("%d%d", &n, &ki);
  for (int i = 1, x, y, l, r; i <= ki; ++i) {
    static char c[3];
    scanf("%d%d%s", &x, &y, c);
    if (x > y) swap(x, y);
    l = y - x - 1;
    r = x + y - 1;
    if (r > n) r = (n << 1) - r;
    if (l <= 0)
      Merge(r, n + 1, *c == 'o');
    else
      Merge(l, r, *c == 'o');
  }
  int ans = 1;
  for (int i = 1; i <= n; ++i)
    if (!fa[i] && (ans = ans + ans) >= MOD) ans -= MOD;
  printf("%d", ans);
  return 0;
}
