#include <bits/stdc++.h>
using namespace std;
template <class _T_>
void read(_T_& d) {
  d = 0;
  int f = 1;
  char c = getchar();
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') f *= -1;
  for (; c >= '0' && c <= '9'; c = getchar()) d = d * 10 + c - '0';
  d *= f;
}
int f[100005];
int d[100005];
int gf(int x) {
  if (f[x] == -1) return x;
  int F = gf(f[x]);
  d[x] = d[f[x]] ^ d[x];
  f[x] = F;
  return F;
}
int mg(int x, int y, int on) {
  int xx = gf(x), yy = gf(y);
  if (xx == yy) {
    if (d[x] ^ d[y] ^ on)
      return 0;
    else
      return 1;
  }
  d[xx] = d[x] ^ d[y] ^ on;
  f[xx] = yy;
  return 1;
}
int n, m;
char c[2];
int main() {
  read(n);
  read(m);
  memset(f, -1, sizeof f);
  int res = 1;
  for (int i = 1, x, y; i <= m; ++i) {
    read(x);
    read(y);
    if (x + y > n + 1) x = n + 1 - x, y = n + 1 - y;
    if (x > y) swap(x, y);
    scanf("%s", c);
    res *= mg(y - x + 1, x + y + 1, c[0] == 'o');
  }
  for (int i = 1; i <= n + 2; ++i)
    if (f[i] == -1) (res *= 2) %= 1000000007;
  cout << 1ll * res * 250000002 % 1000000007 << endl;
  return 0;
}
