#include <bits/stdc++.h>
using namespace std;
vector<string> s;
int c[40];
int v[40];
int n, m;
long long testa() {
  long long ret = 1;
  for (int i = 0; i < m; i++) {
    int cnt = 0;
    for (int j = 0; j < n; j++)
      if (v[j] == s[i][j] - '0') cnt++;
    if (cnt != c[i]) return 0;
  }
  return ret;
}
long long escolhe(int rem, int p) {
  if (rem == 0) {
    for (int i = p; i < n; i++) v[i] = (s[0][i] - '0' + 1) % 2;
    return testa();
  }
  if (p == n) return 0;
  long long ret = 0;
  v[p] = s[0][p] - '0';
  ret += escolhe(rem - 1, p + 1);
  v[p] = (v[p] + 1) % 2;
  ret += escolhe(rem, p + 1);
  return ret;
}
long long f() { return escolhe(c[0], 0); }
int main() {
  scanf("%d%d", &n, &m);
  s.resize(m);
  for (int i = 0; i < m; i++) cin >> s[i] >> c[i];
  printf("%lld\n", f());
  return 0;
}
