#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int k, l;
  vector<int> S(M, 0), P(M);
  for (int i = (0); i < (M); i++) {
    cin >> k;
    for (int j = (0); j < (k); j++) {
      cin >> l;
      S[j] |= 1 << (l - 1);
    }
  }
  for (int i = (0); i < (M); i++) cin >> P[i];
  int ans = 0;
  bool isok;
  for (int bit = (0); bit < (1 << N); bit++) {
    isok = true;
    for (int i = (0); i < (M); i++) {
      isok = __builtin_popcount(bit & S[i]) % 2 == P[i];
      if (!isok) break;
    }
    if (isok) ans++;
  }
  cout << ans << endl;
  return (0);
}
