#include <bits/stdc++.h>
using namespace std;
char back(const std::string& str) { return str[str.size() - 1]; }
int main(int argc, char* argv[]) {
  int n, m;
  cin >> n >> m;
  vector<int> flaws;
  vector<string> tries;
  for (int i = 0; i < (int)(m); ++i) {
    string s;
    cin >> s;
    int f;
    cin >> f;
    tries.push_back(s);
    flaws.push_back(f);
  }
  vector<int> p(n);
  for (int i = 0; i < flaws[0]; ++i) p[p.size() - 1 - i] = 1;
  long long res = 0;
  do {
    string cypher(n, '0');
    for (int i = 0; i < (int)(n); ++i)
      if (p[i])
        cypher[i] = tries[0][i];
      else
        cypher[i] = tries[0][i] == '0' ? '1' : '0';
    bool ok = true;
    for (int i = (int)1; i <= (int)m - 1; ++i) {
      int correct = 0;
      for (int j = 0; j < (int)(n); ++j) {
        if (cypher[j] == tries[i][j]) correct++;
      }
      if (correct != flaws[i]) {
        ok = false;
        break;
      }
    }
    if (ok) res++;
  } while (next_permutation(p.begin(), p.end()));
  cout << res << "\n";
  int temp;
  std::cin >> temp;
}
