#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> SW(N);
  for (size_t i = 0; i < M; i++) {
    int K = 0;
    cin >> K;
    for (size_t j = 0; j < K; j++) {
      int sw_id = 0;
      cin >> sw_id;
      sw_id--;
      SW.at(sw_id) |= (1 << i);
    }
  }
  int P = 0;
  for (size_t i = 0; i < M; i++) {
    int x;
    cin >> x;
    P |= x << i;
  }
  int total = 0;
  for (size_t s = 0; s < (1 << N - 1); s++) {
    int t = 0;
    for (size_t i = 0; i < N; i++) {
      if ((s >> i) & 1) {
        t ^= SW.at(i);
      }
    }
    if (t == P) {
      total++;
    }
  }
  cout << total << endl;
}
