#include <bits/stdc++.h>
using namespace std;
const int p = 1000000007;
int f[300000];
int i, m, n, s, t, x, y, fx, fy, t1, t2;
char c;
inline int getfather(int x) {
  if (f[x] == x)
    return x;
  else
    return f[x] = getfather(f[x]);
}
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= 2 * n + 4; i++) f[i] = i;
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    getchar(), c = getchar();
    t1 = max(x, y) - min(x, y) + 1;
    t2 = min(x + y - 1, 2 * n - x - y + 1) + 2;
    if (c == 'o') {
      fx = getfather(t1);
      fy = getfather(t2 + n + 2);
      if (fx != fy) f[fx] = fy;
      fx = getfather(t2);
      fy = getfather(t1 + n + 2);
      if (fx != fy) f[fx] = fy;
    } else {
      fx = getfather(t1);
      fy = getfather(t2);
      if (fx != fy) f[fx] = fy;
      fy = getfather(t1 + n + 2);
      fx = getfather(t2 + n + 2);
      if (fx != fy) f[fx] = fy;
    }
  }
  for (i = 1; i <= 2 * n + 4; i++) f[i] = getfather(i);
  s = 1, t = 0;
  for (i = 1; i <= 2 * n + 4; i++)
    if (f[i] == f[i + n + 2])
      s = 0;
    else if ((f[i] != f[1]) && (f[i] != f[2]) && (f[i] != f[n + 3]) &&
             (f[i] != f[n + 4]) && (f[i] == i))
      t++;
  for (i = 1; i <= t / 2; i++) s = (s + s) % p;
  printf("%d", s);
  return 0;
}
