#include <bits/stdc++.h>
const long long MOD = 1000000007;
using namespace std;
struct Solver {
  bool contra;
  int n, m;
  vector<pair<int, int> > v[100005];
  int mark[100005];
  Solver() {
    fill(mark, mark + 100005, -1);
    n = m = 0;
    contra = false;
  }
  void push(int a, int b, int c) {
    v[a - 1].push_back({b, c});
    v[b].push_back({a - 1, c});
    m++;
  }
  void dfs(int node, int val) {
    mark[node] = val;
    for (int i = 0; i < v[node].size(); i++) {
      int y = v[node][i].first;
      int c = v[node][i].second;
      if (mark[y] == -1)
        dfs(y, val ^ c);
      else if (mark[y] != val ^ c)
        contra = true;
    }
  }
  long long ans() {
    long long ans = 1;
    dfs(0, 0);
    for (int i = 1; i <= n; i++)
      if (mark[i] == -1) {
        dfs(i, 0);
        ans = (ans * 2) % MOD;
      }
    if (contra) return 0;
    return ans;
  }
} solver[2];
int main() {
  int n, k;
  int a, b, c;
  char ch;
  cin >> n >> k;
  solver[0].n = (n + 1) / 2;
  solver[1].n = n / 2;
  for (int i = 0; i < k; i++) {
    cin >> a >> b >> ch;
    c = (ch == 'x') ? 0 : 1;
    a--;
    b--;
    if (a + b < n) {
      int tmp = a;
      a = n - b - 1;
      b = n - tmp - 1;
    }
    if (n - a - 1 + b < n) swap(a, b);
    int x1 = (a - (n - 1 - b)), x2 = (a + (n - 1 - b));
    solver[x1 % 2].push(x1 / 2 + 1, x2 / 2 + 1, c);
  }
  cout << (solver[0].ans() * solver[1].ans()) % MOD << endl;
  return 0;
}
