#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> k(M);
  vector<vector<int>> s(M);
  vector<int> p(M);
  for (int i = 0; i < M; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < M; i++) cin >> p[i];
  int ans = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    bool ok = true;
    for (int i = 0; i < M; i++) {
      int sum = 0;
      for (auto v : s[i]) {
        if (v & bit) sum++;
      }
      if (sum % 2 != 0) ok = false;
    }
    if (ok) ans += 1;
  }
  cout << ans;
  return 0;
}
