#include <bits/stdc++.h>
using namespace std;
vector<int> v;
vector<vector<int> > T;
int n, m;
long long sol;
bool can[55];
char ans[55];
void f(int idx, int rem) {
  if (rem == 0) {
    T.push_back(v);
    return;
  }
  if (idx == n) return;
  f(idx + 1, rem);
  v.push_back(idx);
  f(idx + 1, rem - 1);
  v.pop_back();
}
int main() {
  scanf("%d %d", &n, &m);
  vector<pair<int, string> > r(m);
  for (int i = 0; i < int(m); i++) cin >> r[i].second >> r[i].first;
  sort(r.begin(), r.end());
  f(0, r[0].first);
  for (int t = 0; t < int(int(T.size())); t++) {
    for (int i = int(0); i <= int(n); i++) can[i] = 0;
    for (int v = 0; v < int(int(T[t].size())); v++) can[T[t][v]] = 1;
    for (int i = 0; i < int(n); i++) {
      if (can[i])
        ans[i] = r[0].second[i];
      else {
        if (r[0].second[i] == '0')
          ans[i] = '1';
        else
          ans[i] = '0';
      }
    }
    bool flag = 1;
    for (int i = int(1); i <= int(m - 1); i++) {
      int cnt = 0;
      for (int j = 0; j < int(n); j++) {
        if (ans[j] == r[i].second[j]) cnt++;
      }
      if (cnt != r[i].first) {
        flag = 0;
        break;
      }
    }
    if (flag) {
      sol++;
    }
  }
  cout << sol << endl;
  return 0;
}
