#include <bits/stdc++.h>
using namespace std;
int N, M;
int K[11];
int S[11][11];
int P[11];
int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> K[i];
    for (int k = 0; k < K[i]; k++) {
      int nu;
      cin >> nu;
      S[i][k] = nu - 1;
    }
  }
  int ans = 0;
  for (int i = 0; i < M; i++) {
    cin >> P[i];
  }
  for (int bit = 0; bit < (1 << N); bit++) {
    int mana[11];
    memset(mana, 0, sizeof(mana));
    for (int i = 0; i < N; i++) {
      if (bit & (1 << i)) {
        for (int m = 0; m < M; m++) {
          if (binary_search(S[m], S[m] + K[m], i)) {
            mana[m] += 1;
          }
        }
      }
    }
    bool flag = true;
    for (int i = 0; i < M; i++) {
      if (mana[i] % 2 != P[i]) flag = false;
    }
    if (flag) ans++;
  }
  cout << ans << endl;
  return 0;
}
