#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
void ckmin(T &a, U b) {
  if (a > b) a = b;
}
template <class T, class U>
void ckmax(T &a, U b) {
  if (a < b) a = b;
}
int N, M;
int dsu[100013];
vector<pair<int, int> > edge[100013];
bitset<100013> val;
vector<pair<pair<int, int>, bool> > checks;
long long ans;
int get(int u) { return (u == dsu[u] ? u : dsu[u] = get(dsu[u])); }
bool merge(int u, int v) {
  u = get(u);
  v = get(v);
  if (u == v) return false;
  dsu[u] = v;
  return true;
}
pair<int, int> gen(int x, int y) {
  if ((x + y) & 1) {
    int dif = (N + 1) >> 1;
    if (y == x + 1) return {dif + x, N};
    return {dif + ((y - x - 2) >> 1), dif + ((y + x) >> 1)};
  } else {
    if (x == y) return {x, N};
    return {((y - x - 2) >> 1), ((y + x) >> 1)};
  }
}
void setv(int x, int y, bool va) {
  pair<int, int> p = gen(x, y);
  int u = p.first, v = p.second;
  if (merge(u, v)) {
    edge[u].push_back({v, va});
    edge[v].push_back({u, va});
  } else {
    checks.push_back({{u, v}, va});
  }
}
void dfs(int u, int p) {
  for (auto e : edge[u]) {
    int v = e.first;
    bool b = e.second;
    if (v == p) continue;
    val[v] = val[u] ^ b;
    dfs(v, u);
  }
}
long long expo(long long a, long long e) {
  if (e == 0) return 1;
  if (e & 1) {
    return a * expo(a * a % 1000000007, e >> 1) % 1000000007;
  }
  return expo(a * a % 1000000007, e >> 1);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M;
  for (auto i = (0); i < (N + 1); i++) {
    dsu[i] = i;
  }
  for (auto i = (0); i < (M); i++) {
    int x, y, v;
    char c;
    cin >> x >> y >> c;
    x--;
    y--;
    v = (c == 'o' ? 1 : 0);
    if (x > y) swap(x, y);
    if (x + y >= N) {
      x = N - 1 - x;
      y = N - 1 - y;
      swap(x, y);
    }
    setv(x, y, v);
  }
  for (auto i = (0); i < (N + 1); i++) {
    if (get(i) == i) {
      val[i] = 0;
      dfs(i, N + 1);
      ans++;
    }
  }
  for (auto a : checks) {
    if (a.second != val[a.first.first] ^ val[a.first.second]) {
      cout << "0\n";
      return 0;
    }
  }
  ans--;
  ans = expo(2, ans);
  cout << ans << '\n';
  return 0;
}
