#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, M, K, x;
  cin >> N >> M;
  vector<long long> P(M);
  vector<vector<long long>> A(M);
  for (int i = 0; i < M; i++) {
    cin >> K;
    for (int k = 0; k < K; k++) {
      cin >> x;
      x--;
      A[i].push_back(x);
    }
  }
  sort(A.begin(), A.end());
  for (int i = 0; i < M; i++) {
    cin >> P[i];
  }
  int Count = 0;
  for (int i = 0; i < (1 << N); i++) {
    int m_count = 0;
    for (int m = 0; m < M; m++) {
      int l_count = 0;
      for (int l = 0; l < N; l++) {
        if ((i >> l) & 1)
          if (binary_search(A[m].begin(), A[m].end(), l)) l_count++;
      }
      if (l_count % 2 == P[m]) m_count++;
    }
    if (m_count == M) Count++;
  }
  cout << Count;
}
