#include <bits/stdc++.h>
using namespace std;
int n, m, ans;
vector<string> a;
vector<int> b;
vector<bool> c;
void gen(int ind, int k) {
  if (k == 0) {
    bool yes = true;
    int t;
    for (int i = 1; i < m && yes; i++) {
      t = 0;
      for (int j = 0; j < n; j++)
        if (c[j] && a[0][j] == a[i][j] || !c[j] && a[0][j] != a[i][j]) t++;
      if (t != b[i]) yes = false;
    }
    ans += yes;
    return;
  } else if (k > n - ind)
    return;
  else {
    c[ind] = true;
    gen(ind + 1, k - 1);
    c[ind] = false;
    gen(ind + 1, k);
  }
}
int main() {
  cin >> n >> m;
  a.resize(m);
  b.resize(m);
  c.resize(n);
  for (int i = 0; i < m; i++) cin >> a[i] >> b[i];
  gen(0, b[0]);
  cout << ans;
  return 0;
}
