#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
inline long long lin() {
  long long x;
  scanf("%lld", &x);
  return x;
}
char ch[4000010];
inline string get() {
  scanf("%s", ch);
  return string(ch);
}
inline void read(int *a, int n) {
  for (int i = 0; i < n; i++) a[i] = in();
}
template <class blank>
inline void out(blank x) {
  cout << x << "\n";
  exit(0);
}
template <class blank, class blank2>
inline void smin(blank &a, blank2 b) {
  a = a <= b ? a : b;
}
template <class blank, class blank2>
inline void smax(blank &a, blank2 b) {
  a = a >= b ? a : b;
}
const int maxn = 3e5 + 10;
const int maxm = 4e6 + 10;
const int maxlg = 20;
const int base = 29;
const int mod = 1e9 + 7;
const int inf = 2e18 + 10;
const double eps = 1e-9;
string code[maxn];
int correct[maxn];
int mark[maxn];
int n, m;
int res;
inline void bt(int pos = 0, int cnt = 0) {
  if (cnt > correct[0] || n - pos + cnt < correct[0]) return;
  if (pos == n) {
    string cc = code[0];
    for (int i = 0; i < n; i++) {
      if (mark[i] == 0) {
        cc[i] ^= '1' ^ '0';
      }
    }
    bool fl = true;
    for (int i = 0; i < m; i++) {
      int diff = 0;
      for (int j = 0; j < n; j++) diff += code[i][j] != cc[j];
      if (diff != n - correct[i]) fl = false;
    }
    res += fl;
    return;
  }
  bt(pos + 1, cnt);
  mark[pos] = true;
  bt(pos + 1, cnt + 1);
  mark[pos] = false;
}
int32_t main() {
  n = in(), m = in();
  for (int i = 0; i < m; i++) {
    code[i] = get(), correct[i] = in();
  }
  bt(0);
  cout << res << "\n";
}
