Toastman came up with a very complicated task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?

Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o', or nothing. How many ways to fill all the empty cells with 'x' or 'o' (each cell must contain only one character in the end) are there, such that for each cell the number of adjacent cells with 'o' will be even? Find the number of ways modulo 1000000007 (109 + 7). Two cells of the board are adjacent if they share a side.

Input

The first line contains two integers n, k (1 ≤ n, k ≤ 105) — the size of the board, and the number of cells that has characters initially. 

Then k lines follows. The i-th line contains two integers and a character: ai, bi, ci (1 ≤ ai, bi ≤ n; ci is either 'o' or 'x'). This line means: there is a character ci in the cell that is located on the intersection of the ai-th row and bi-th column. All the given cells are distinct.

Consider that the rows are numbered from 1 to n from top to bottom. Analogically, the columns are numbered from 1 to n from left to right.

Output

Print a single integer — the answer to the problem.

Examples

Input

3 2
1 1 x
2 2 o


Output

2


Input

4 3
2 4 x
3 4 x
3 2 x


Output

2

Note

In the first example there are two ways:
    
    
      
        xxo          xoo  
        xox          ooo  
        oxx          oox  
    
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = int(1e5) + 10;
const int MOD = int(1e9) + 7;
struct Edge {
  int t, c;
  Edge(int t, int c) : t(t), c(c) {}
};
vector<Edge> E[MAX_N];
int n, k;
void addEdge(int u, int v, int c) {
  E[u].push_back(Edge(v, c));
  E[v].push_back(Edge(u, c));
}
bool bad;
int col[MAX_N];
void dfs(int u, int what) {
  if (bad) return;
  if (col[u] != -1) {
    if (col[u] != what) {
      bad = true;
    }
    return;
  }
  col[u] = what;
  for (vector<Edge>::iterator e = E[u].begin(); e != E[u].end(); ++e) {
    dfs(e->t, what ^ e->c);
  }
}
void constraint(int r, int c, int v) {
  int d = min(r - 1, c - 1);
  d = min(d, n - r);
  d = min(d, n - c);
  int cc = abs(r - c) + d + 1;
  int L = cc - d, R = cc + d;
  L -= 2;
  if (L < 0) L = 0;
  if (R > n) R = n;
  addEdge(L, R, v);
}
int main() {
  cin >> n >> k;
  while (k--) {
    int r, c, v;
    scanf("%d%d", &r, &c);
    char ch;
    scanf(" ");
    scanf("%c", &ch);
    if (ch == 'o')
      v = 1;
    else
      v = 0;
    constraint(r, c, v);
  }
  memset(col, -1, sizeof col);
  int cnt = 0;
  bad = false;
  for (int i = 0; i <= n; ++i) {
    if (bad) break;
    if (col[i] == -1) {
      dfs(i, 0);
      ++cnt;
    }
  }
  if (bad) {
    puts("0");
    return 0;
  }
  int ans = 1;
  --cnt;
  while (cnt--) ans = (ans + ans) % MOD;
  cout << ans << endl;
}
