#include <bits/stdc++.h>
using namespace std;
const int maxn = 15;
string str[maxn], s;
int n, m, ans, data[maxn];
bool check() {
  for (int i = 1; i <= m; i++) {
    int cnt = 0;
    for (int j = 0; j < n; j++)
      if (s[j] == str[i][j]) cnt++;
    if (cnt != data[i]) return false;
  }
  return true;
}
void search(int com, int c) {
  if (c < 0) return;
  if (com == n) {
    if (c == 0 && check()) ans++;
    return;
  }
  s[com] = '0' + (s[com] - '0') ^ 1;
  search(com + 1, c);
  s[com] = '0' + (s[com] - '0') ^ 1;
  search(com + 1, c - 1);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) cin >> str[i] >> data[i];
  s = str[1];
  search(0, data[1]);
  printf("%d\n", ans);
  return 0;
}
