#include <bits/stdc++.h>
using namespace std;
void gao(long long now, int c, int x, int n, vector<long long>& r) {
  if (!c) {
    for (int i = x; i < n; now ^= 1ll << i++)
      ;
    r.push_back(now);
  } else {
    for (int i = x; i < n; now ^= 1ll << i++) gao(now, c - 1, i + 1, n, r);
  }
}
int main() {
  int n, m, c;
  char str[50];
  scanf("%d%d", &n, &m);
  vector<long long> u;
  for (int i = 0; i < m; i++) {
    long long now = 0;
    scanf("%s%d", str, &c);
    for (int j = 0; j < n; j++) now |= str[j] - 48ll << j;
    vector<long long> r;
    gao(now, c, 0, n, r);
    sort(r.begin(), r.end());
    if (!i)
      u = r;
    else
      u.resize(
          set_intersection(u.begin(), u.end(), r.begin(), r.end(), u.begin()) -
          u.begin());
  }
  printf("%d\n", u.size());
}
