#include <bits/stdc++.h>
const double eps = (1e-10);
using namespace std;
int dcmp(double a, double b) {
  return fabs(a - b) <= eps ? 0 : (a > b) ? 1 : -1;
}
int getBit(int num, int idx) { return ((num >> idx) & 1) == 1; }
int setBit1(int num, int idx) { return num | (1 << idx); }
int setBit0(int num, int idx) { return num & ~(1 << idx); }
int flipBit(int num, int idx) { return num ^ (1 << idx); }
int countNumBit1(int mask) {
  int ret = 0;
  while (mask) {
    mask &= (mask - 1);
    ++ret;
  }
  return ret;
}
string str;
vector<string> v1;
vector<pair<string, int> > v;
map<string, int> vis;
int n, num, vs[100];
void put(int vs[]) {
  string strr = str;
  for (int i = 0; i < n; i++) {
    if (!vs[i]) {
      strr[i] = (strr[i] == '0' ? '1' : '0');
    }
  }
  v1.push_back(strr);
}
void fun(int st, int c) {
  if (c == num) {
    put(vs);
    return;
  }
  for (int i = st; i < n; i++) {
    vs[i] = 1;
    fun(i + 1, c + 1);
    vs[i] = 0;
  }
  return;
}
bool check(string s1, string s2, int sam) {
  int cnt = 0;
  for (int i = 0; i < ((int)(s1).size()); i++) {
    if (s1[i] == s2[i]) cnt++;
  }
  if (cnt == sam) return 1;
  return 0;
}
int main() {
  int m;
  scanf("%d %d", &n, &m);
  char stt[39];
  string st;
  int rig;
  for (int i = 0; i < m; i++) {
    scanf("%s %d", &stt, &rig);
    st = stt;
    vis[st] = 1;
    v.push_back(make_pair(st, rig));
  }
  str = v[0].first;
  num = v[0].second;
  fun(0ll, 0);
  long long ans = 0;
  for (int i = 0; i < ((int)(v1).size()); i++) {
    st = v1[i];
    bool ok = 1;
    for (int j = 1; j < m && ok; j++) {
      if (!check(st, v[j].first, v[j].second)) ok = 0;
    }
    if (ok) {
      if (vis.find(v1[i]) == vis.end()) ans++;
    }
  }
  printf("%I64d\n", ans);
}
