#include <bits/stdc++.h>
using namespace std;
inline long long gi() {
  long long x = 0;
  bool f = 0;
  char ch = getchar();
  while (!isdigit(ch)) f |= ch == '-', ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  return f ? -x : x;
}
inline void pi(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) pi(x / 10);
  putchar(48 + x % 10);
}
inline void pin(long long x) {
  pi(x);
  putchar('\n');
}
inline void pib(long long x) {
  pi(x);
  putchar(' ');
}
const long long N = 5e5 + 5, mo = 1e9 + 7;
long long fa[N], n, m;
long long find(long long x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
inline void mer(long long x, long long y) { fa[find(x)] = find(y); }
signed main() {
  n = gi(), m = gi();
  for (register long long i = (0); i <= (n * 2 + 3); ++i) fa[i] = i;
  for (register long long i = (1); i <= (m); ++i) {
    long long x = gi(), y = gi();
    char s[10];
    scanf("%s", s);
    long long l = abs(y - x),
              r = ((x + y) < (2 * n - (x + y - 2)) ? (x + y)
                                                   : (2 * n - (x + y - 2))),
              chk = s[0] == 'o';
    mer(l * 2, 2 * r + chk);
    mer(l * 2 + 1, 2 * r + (chk ^ 1));
  }
  for (register long long i = (0); i <= (n + 1); ++i)
    if (find(2 * i) == find(2 * i + 1)) {
      puts("0");
      return 0;
    }
  long long ans = 1, cnt = 0;
  for (register long long i = (0); i <= (2 * n + 3); ++i) cnt += fa[i] == i;
  cnt = (cnt - 4) / 2;
  for (register long long i = (1); i <= (cnt); ++i) ans = 2 * ans % mo;
  pin(ans);
}
