#include <bits/stdc++.h>
#pragma comment(linker, "/stack:32000000")
using namespace std;
const int INF = 2147483647;
const long long LLINF = 9223372036854775807LL;
const int maxn = 100010;
vector<int> a[maxn];
vector<int> w[maxn];
int u[maxn];
void dfs(int x, int color) {
  if (u[x] != -1) {
    if (u[x] != color) printf("0\n"), exit(0);
    return;
  }
  u[x] = color;
  for (int i = 0; i < int((a[x]).size()); ++i) dfs(a[x][i], w[x][i] ^ color);
}
int main() {
  int n;
  scanf("%d", &n);
  int k;
  scanf("%d", &k);
  for (int i = 0; i < k; ++i) {
    int ci, cj;
    scanf("%d%d", &ci, &cj);
    char c = 0;
    while (c != 'o' && c != 'x') c = getchar();
    int val = c == 'o';
    --ci, --cj;
    if (ci > cj) swap(ci, cj);
    if (ci + cj >= n) ci = n - 1 - ci, cj = n - 1 - cj, swap(ci, cj);
    int fr = cj - ci;
    int to = ci + cj;
    fr = (fr + n) % (n + 2);
    a[fr].push_back(to);
    w[fr].push_back(val);
    a[to].push_back(fr);
    w[to].push_back(val);
  }
  int cc = 0;
  memset(u, -1, sizeof(u));
  for (int i = 0; i < n + 2; ++i)
    if (u[i] == -1) ++cc, dfs(i, 0);
  cc -= 2;
  const int mod = 1000000007;
  int ans = 1;
  for (int iter = 0; iter < cc; ++iter) ans = (ans + ans) % mod;
  printf("%d\n", ans);
  return 0;
}
