#include <bits/stdc++.h>
using namespace std;
int n, m;
int sum[(100)], ans[(100)];
int g[(100)][(100)];
int minsum, tot;
char buf[(100)];
void init() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%s%d", buf, &sum[i]);
    if (minsum == 0 || sum[i] < sum[minsum]) minsum = i;
    for (int j = 0; j < n; j++) g[i][j + 1] = buf[j] - '0';
  }
}
bool check() {
  for (int i = 1; i <= m; i++) {
    int tmp = 0;
    for (int j = 1; j <= n; j++)
      if (g[i][j] == ans[j]) tmp++;
    if (tmp != sum[i]) {
      return false;
    }
  }
  return true;
}
void dfs(int step, int now) {
  if (step > n && now == 0) {
    if (check()) tot++;
    return;
  }
  if (step > n) return;
  ans[step] = (g[minsum][step] ^ 1);
  dfs(step + 1, now);
  if (now > 0) {
    ans[step] = (g[minsum][step]);
    dfs(step + 1, now - 1);
  }
}
void work() {
  dfs(1, sum[minsum]);
  printf("%d\n", tot);
}
int main() {
  init();
  work();
  return 0;
}
