#include <bits/stdc++.h>
using namespace std;
long long N, M;
long long K[11];
long long Q[11];
long long S[11][11];
long long n;
long long ans;
bool found;
int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> K[i];
    for (int j = 0; j < K[i]; j++) {
      cin >> S[i][j];
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> Q[i];
  }
  for (int bit = 0; bit < (1 << N); ++bit) {
    n = 0;
    found = true;
    for (int j = 0; j < M; j++) {
      for (int k = 0; k < K[j]; k++) {
        if (bit & 1 << (S[j][k] - 1)) {
          n++;
        }
      }
      if (n % 2 != Q[j]) {
        found = false;
      }
    }
    if (found) {
      ans++;
    }
  }
  cout << ans << endl;
}
