#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;
int main() {
  int n, m, k, s, cnt = 0, lampcnt = 0, ans = 0;
  cin >> n >> m;
  vector<vector<int>> lamp(m, vector<int>());
  vector<int> lampm(m);
  vector<int> si(m, 0), sii(m, 0);
  for (int i = 0; i < (int)(m); i++) {
    cin >> k;
    for (int i = 0; i < (int)(k); i++) {
      cin >> s;
      lamp[i].push_back(s);
    }
    cin >> lampm[i];
  }
  for (int bit = 0; bit < (1 << n); bit++) {
    si = sii;
    for (int i = 0; i < (int)(n); i++) {
      if (bit & (1 << (n - 1)) >> i) {
        si[i] = 1;
      }
    }
    cnt = 0;
    lampcnt = 0;
    for (int i = 0; i < (int)(m); i++) {
      for (int j = 0; j < (int)(n); j++) {
        if (si[j] == lamp[i][j]) cnt++;
      }
      if (cnt % 2 == lampm[i]) lampcnt++;
    }
    if (lampcnt == m) ans++;
  }
  cout << ans << endl;
  return 0;
}
