#include <bits/stdc++.h>
using namespace std;
template <class T>
T inline sqr(T x) {
  return x * x;
}
const int maxm = 10 + 3;
const int maxn = 35 + 3;
int res = 0, n, m, K[maxm];
char s[maxm][maxn], z[maxm];
void go(int i, int k) {
  if (i == n) {
    int good = 1;
    for (int i = 0; i < (int)(m); i++) {
      int cnt = 0;
      for (int j = 0; j < (int)(n); j++) cnt += (z[j] != s[i][j]);
      good &= (cnt == K[i]);
    }
    res += good;
    return;
  }
  z[i] = s[0][i];
  go(i + 1, k);
  z[i] ^= 1;
  if (k > 0) go(i + 1, k - 1);
}
int main() {
  scanf("%d%d ", &n, &m);
  for (int i = 0; i < (int)(m); i++) scanf("%s%d", s[i], &K[i]);
  go(0, K[0]);
  printf("%d\n", res);
  return 0;
}
