#include <bits/stdc++.h>
using namespace std;
const int MAXN = 64;
int n, m, k[MAXN];
int ans;
string s[MAXN];
void solve(int pos) {
  for (int i = (0); i < (int)(m); i++)
    if (k[i] < 0) return;
  if (pos == n) {
    for (int i = (0); i < (int)(n); i++) {
      if (k[i] != 0) return;
    }
    ans++;
    return;
  }
  for (int i = (0); i < (int)(m); i++)
    if (s[i][pos] == '0') k[i]--;
  solve(pos + 1);
  for (int i = (0); i < (int)(m); i++)
    if (s[i][pos] == '0') k[i]++;
  for (int i = (0); i < (int)(m); i++)
    if (s[i][pos] == '1') k[i]--;
  solve(pos + 1);
  for (int i = (0); i < (int)(m); i++)
    if (s[i][pos] == '1') k[i]++;
}
int main() {
  while (scanf("%d%d", &n, &m) >= 1) {
    ans = 0;
    for (int i = (0); i < (int)(m); i++) {
      cin >> s[i];
      scanf("%d", &k[i]);
    }
    solve(0);
    printf("%d\n", ans);
  }
  return 0;
}
