#include <bits/stdc++.h>
using namespace std;
long long BitStringToLL(const string& str) {
  long long ret = 0;
  for (int i = (int)str.size() - 1; i >= 0; i--)
    if (str[i] == '1') ret |= 1ll << (str.size() - 1 - i);
  return ret;
}
void SetBitEqual(long long& value, int i, const long long& from) {
  if ((1ll << i) & from)
    value |= (1ll << i);
  else
    value &= ~(1ll << i);
}
void GenerateVariants(int index, int n, int count, const long long& value,
                      const long long& inv_value, long long& current,
                      list<long long>& variants) {
  if (count == 0) {
    variants.push_back(current);
    return;
  }
  for (int i = index; i < n; i++) {
    SetBitEqual(current, i, value);
    GenerateVariants(i + 1, n, count - 1, value, inv_value, current, variants);
    SetBitEqual(current, i, inv_value);
  }
}
bool BitEqual(long long value, int count) {
  while (value != 0) {
    if (count == 0) return false;
    value &= value - 1;
    count--;
  }
  return (count == 0);
}
void CheckVariants(list<long long>& variants, long long value, int c) {
  for (list<long long>::iterator p = variants.begin(); p != variants.end();)
    if (BitEqual(~(*p ^ value), c))
      p++;
    else
      p = variants.erase(p);
}
int main() {
  int n, m;
  cin >> n >> m;
  list<long long> variants;
  for (int i = 0; i < m; i++) {
    string str;
    int c;
    cin >> str >> c;
    long long value = BitStringToLL(str);
    if (i == 0) {
      long long current = ~value;
      GenerateVariants(0, n, c, value, ~value, current, variants);
    } else
      CheckVariants(variants, value, c);
  }
  cout << variants.size() << endl;
  return 0;
}
