#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> sw;
  vector<int> p;
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    vector<int> swit;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      swit.push_back(s);
    }
    sw.push_back(swit);
    int ptmp;
    cin >> ptmp;
    p.push_back(ptmp);
  }
  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {
    bitset<10> b(i);
    bool ok = true;
    for (int j = 0; j < m; j++) {
      int count = 0;
      for (int k = 0; k < sw.at(j).size(); k++) {
        if (b.test(sw.at(j).at(k))) count++;
      }
      if (count % 2 != p.at(j)) ok = false;
    }
    if (ok) {
      ans++;
    }
  }
  cout << ans << endl;
}
