#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 10, MOD = 1e9 + 7;
const int MN = 1e5 + 10;
int n, k;
int cmp;
int par[MN], sz[MN], col[MN];
int x[MN], y[MN];
char ch[MN];
vector<int> vec[MN];
long long ans = 1;
vector<pair<pair<int, int>, bool> > my;
void fail() {
  cout << 0 << endl;
  exit(0);
}
int root(int a) {
  if (par[a] == a) return a;
  return par[a] = root(par[a]);
}
void Union(int a, int b, bool f) {
  if (root(a) == root(b)) {
    if (f == (col[a] != col[b])) return;
    fail();
  }
  --cmp;
  if (sz[root(a)] > sz[root(b)]) swap(a, b);
  int rb = root(b), ra = root(a);
  sz[rb] += sz[ra];
  par[ra] = rb;
  if ((f && col[a] == col[b]) || (!f && col[a] != col[b])) {
    while (!vec[ra].empty()) {
      col[vec[ra].back()] = !col[vec[ra].back()];
      vec[rb].push_back(vec[ra].back());
      vec[ra].pop_back();
    }
  } else {
    while (!vec[ra].empty()) {
      vec[rb].push_back(vec[ra].back());
      vec[ra].pop_back();
    }
  }
}
void clear() {
  memset(col, 0, sizeof col);
  for (int i = 0; i <= n; ++i)
    vec[i].clear(), vec[i].push_back(i), sz[i] = 1, par[i] = i;
}
void solve() {
  clear();
  for (int i = 0; i < ((int)(my).size()); ++i)
    Union(my[i].first.first, my[i].first.second, my[i].second);
  for (int i = 0; i < cmp - 1; ++i) {
    ans *= 2;
    if (ans >= MOD) ans -= MOD;
  }
}
void input() {
  cin >> n >> k;
  for (int i = 0; i < k; ++i) {
    cin >> x[i] >> y[i] >> ch[i];
    --x[i], --y[i];
  }
  for (int i = 0; i < k; ++i)
    if ((x[i] + y[i]) % 2 == 0) {
      int tl = abs(x[i] - y[i]) / 2;
      int tr = (n - 1 - abs(x[i] + y[i] - n + 1)) / 2;
      my.push_back(make_pair(make_pair(tl, tr + 1), (ch[i] == 'o')));
    }
  cmp = (n + 1) / 2 + 1;
  solve();
  my.clear();
  for (int i = 0; i < k; ++i)
    if ((x[i] + y[i]) & 1) {
      int tl = (abs(x[i] - y[i]) - 1) / 2;
      int tr = (n - 1 - abs(x[i] + y[i] - n + 1)) / 2;
      my.push_back(make_pair(make_pair(tl, tr + 1), (ch[i] == 'o')));
    }
  cmp = n / 2 + 1;
  solve();
}
int main() {
  ios_base ::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  input();
  cout << ans << endl;
  return 0;
}
