#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> S(M);
  vector<int> P(M);
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      S[i].push_back(s);
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> P[i];
  }
  int ans = 0;
  for (int i = 1; i < (1 << N); i++) {
    int cnt = 0;
    bitset<10> bit(i);
    for (int j = 0; j < M; j++) {
      int tmp = 0;
      for (int x : S[j]) {
        if (bit.test(--x)) {
          tmp++;
        }
      }
      if (tmp % 2 == P[j]) {
        cnt++;
      }
    }
    if (cnt == M) {
      ans++;
    }
  }
  cout << ans << endl;
}
