#include <bits/stdc++.h>
using namespace std;
int n, m, ans = 0;
struct attempt {
  char s[40];
  int c;
} a[15];
bool cmp(const attempt &a, const attempt &b) { return a.c < b.c; }
bool isok(int *t, int id) {
  int c = 0;
  for (int i = 0; i < n; i++) {
    if (t[i] == a[id].s[i] - '0') c++;
  }
  return c == a[id].c;
}
void dfs(int num, int last, int *p) {
  if (num == 0) {
    int t[55];
    memset(t, -1, sizeof(t));
    for (int i = 1; i <= a[0].c; i++) t[p[i]] = a[0].s[p[i]] - '0';
    for (int i = 0; i < n; i++) {
      if (t[i] == -1) {
        t[i] = a[0].s[i] - '0';
        t[i] = 1 - t[i];
      }
    }
    bool ok = true;
    for (int i = 1; i < m; i++)
      if (!isok(t, i)) {
        ok = false;
        break;
      }
    if (ok) ans++;
    return;
  }
  for (int i = last; i < n; i++) {
    p[num] = i;
    dfs(num - 1, i + 1, p);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) scanf("%s%d", a[i].s, &a[i].c);
  sort(a, a + m, cmp);
  int t[40];
  dfs(a[0].c, 0, t);
  printf("%d\n", ans);
  return 0;
}
