#include <bits/stdc++.h>
using namespace std;
vector<pair<string, int> > a;
string aux;
int n, m;
long long res;
int k;
void dfs(int cur, int start, int remain) {
  if (cur == m) {
    res++;
    return;
  }
  if (!cur) {
    if (remain) {
      if (start == n) return;
      dfs(cur, start + 1, remain);
      aux[start] = a[cur].first[start];
      dfs(cur, start + 1, remain - 1);
      aux[start] = '.';
    } else {
      string tmp = aux;
      for (int i = 0; i < n; ++i)
        if (aux[i] == '.') aux[i] = a[cur].first[i] == '1' ? '0' : '1';
      dfs(cur + 1, 0, 0);
      aux = tmp;
    }
  } else {
    int cnt = 0;
    for (int i = 0; i < n; ++i)
      if (aux[i] == a[cur].first[i]) cnt++;
    if (cnt == a[cur].second) dfs(cur + 1, 0, 0);
  }
}
bool cmp(const pair<string, int> &a, const pair<string, int> &b) {
  return a.second < b.second;
}
int main() {
  cin >> n >> m;
  a.resize(m);
  for (int i = 0; i < m; ++i) cin >> a[i].first >> a[i].second;
  sort((a).begin(), (a).end(), cmp);
  for (int i = 0; i < n; ++i) aux.push_back('.');
  res = 0;
  dfs(0, 0, a[0].second);
  cout << res << endl;
}
