#include <bits/stdc++.h>
using namespace std;
int n, m, k, tmp;
string s;
vector<pair<string, int> > vec;
long long ans;
void change(int idx, string &tt) {
  if (tt[idx] == '0')
    tt[idx] = '1';
  else
    tt[idx] = '0';
}
bool compare(string xx) {
  string x = xx;
  for (int i = 0; i < n; ++i) change(i, x);
  for (int i = 0; i < m; ++i) {
    int cnt = 0;
    string t = vec[i].first;
    for (int j = 0; j < n; ++j) {
      if (t[j] == x[j]) ++cnt;
    }
    if (cnt != vec[i].second) return false;
  }
  return true;
}
void combinations(int x, int changes) {
  if (changes == 0) {
    ans += compare(s);
    return;
  }
  if (x >= n) return;
  change(x, s);
  combinations(x + 1, changes - 1);
  change(x, s);
  combinations(x + 1, changes);
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  scanf("%d %d", &n, &m);
  char mo2rf[40];
  for (int i = 0; i < m; ++i) {
    scanf("%s %d", mo2rf, &tmp);
    s = mo2rf;
    vec.push_back({s, tmp});
  }
  s = vec[0].first;
  combinations(0, vec[0].second);
  printf("%I64d\n", ans);
  return 0;
}
