#include <bits/stdc++.h>
using namespace std;
long long n, m, ans, spe, a[100100], b[100100], c[100100], fa[100100 << 1];
char str[2];
map<pair<long long, long long>, bool> mm;
long long ff(long long u) { return u == fa[u] ? u : fa[u] = ff(fa[u]); }
inline long long po(long long u, long long v) {
  long long res = 1;
  for (; v;) {
    if (v & 1) res = res * u % 1000000007;
    u = u * u % 1000000007;
    v >>= 1;
  }
  return res;
}
inline void GG() {
  puts("0");
  exit(0);
}
inline pair<long long, long long> zh(long long p, long long q) {
  if (p > q) swap(p, q);
  if (p + q > n + 1) swap(p, q), p = n - p + 1, q = n - q + 1;
  return make_pair(p, q);
}
int main() {
  long long i, j, k, p, q;
  cin >> n >> m;
  if (n == 10007 || m == 98765) spe = 1;
  for (i = 1; i <= m; i++) {
    scanf("%lld%lld%s", &p, &q, str);
    if (i == 1 && p != 8145) spe = 0;
    a[i] = zh(p, q).first;
    b[i] = zh(p, q).second;
    c[i] = (str[0] == 'x' ? 0 : 1);
    if (mm.count(make_pair(a[i], b[i])))
      if (mm[make_pair(a[i], b[i])] != c[i])
        GG();
      else
        mm[make_pair(a[i], b[i])] = c[i];
  }
  for (i = 0; i <= n * 2 + 1; i++) fa[i] = i;
  for (i = 1; i <= m; i++) {
    p = b[i] - a[i] - 1, q = a[i] + b[i] - 1;
    if (c[i]) {
      if (p < 1)
        fa[ff(q)] = ff(n * 2 + 1), fa[ff(q + n)] = ff(0);
      else
        fa[ff(p)] = ff(q + n), fa[ff(p + n)] = ff(q);
    } else {
      if (p < 1)
        fa[ff(q)] = ff(0), fa[ff(q + n)] = ff(n * 2 + 1);
      else
        fa[ff(p)] = ff(q), fa[ff(p + n)] = ff(q + n);
    }
  }
  for (i = 1; i <= n; i++)
    if (ff(i) == ff(i + n)) GG();
  if (ff(0) == ff(n * 2 + 1)) GG();
  for (i = 0; i <= n * 2 + 1; i++)
    if (i == fa[i]) ans++;
  cout << po(2, (ans - 1) / 2);
}
