#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> S(n);
  for (int k = 0; k < (m); k++) {
    int tmp;
    cin >> tmp;
    for (int i = 0; i < (tmp); i++) {
      int a;
      cin >> a;
      a--;
      S[a] |= 1 << k;
    }
  }
  int p = 0;
  for (int i = 0; i < (m); i++) {
    int tmp;
    cin >> tmp;
    p |= tmp << 1;
  }
  int success = 0;
  for (int bit = 0; bit < ((1 << n)); bit++) {
    int ok = 0;
    for (int i = 0; i < (n); i++) {
      if (bit >> i & 1) {
        ok ^= S[i];
      }
    }
    if (ok == p) success++;
  }
  cout << success << endl;
}
