#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, ans = 0;
  cin >> N >> M;
  int K[M], S[M][10];
  for (int i = (0); i < (M); ++i) {
    cin >> K[i];
    for (int j = (0); j < (K[i]); ++j) cin >> S[i][j];
  }
  int P[M];
  for (int i = (0); i < (M); ++i) cin >> P[M];
  for (int bit = 0; bit < (1 << N); ++bit) {
    int L[N];
    for (int i = (0); i < (N); ++i) L[i] = 0;
    bool CAN2 = false;
    for (int i = 0; i < N; ++i) {
      if (bit & (1 << N)) {
        L[i]++;
        CAN2 = true;
      }
    }
    if (CAN2) {
      bool CAN = true;
      for (int i = (0); i < (M); ++i) {
        int cnt = 0;
        for (int j = (0); j < (K[i]); ++j) {
          if (L[S[i][j] - 1] > 0) cnt++;
        }
        if (P[i] != cnt % 2) CAN = false;
      }
      if (CAN) ans++;
    }
  }
  cout << ans << endl;
}
