#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5;
const long long M = 20;
const long long SQ = 320;
const long long INF = 1e16;
const long long MOD = 1e9 + 7;
int n, k;
string s[N], s1;
int c[N], a[N];
map<long long, int> m;
void bt(int id, int pos, int cnt) {
  if (pos == n) {
    if (cnt != 0) return;
    long long h = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] ^ (s[id][i] - '0') == 1) h++;
      h *= 2;
    }
    m[h]++;
  } else {
    if (cnt > 0) {
      a[pos] = 0;
      bt(id, pos + 1, cnt - 1);
    }
    a[pos] = 1;
    bt(id, pos + 1, cnt);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    cin >> s[i] >> c[i];
    bt(i, 0, c[i]);
  }
  int ans = 0;
  for (auto h : m)
    if (h.second == k) ans++;
  cout << ans << endl;
  return 0;
}
