#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> vec(N, 0);
  for (int m = 0; m < M; m++) {
    int K;
    cin >> K;
    for (int k = 0; k < K; k++) {
      int s;
      cin >> s;
      vec[s - 1] = vec[s - 1] | (1 << m);
    }
  }
  int lon = 0;
  for (int m = 0; m < M; m++) {
    int t;
    cin >> t;
    lon = lon | (t << m);
  }
  int ans = 0;
  for (int i = 0; i <= (1 << N); i++) {
    int son = 0;
    for (int n = 0; n < N; n++) {
      if (i & (1 << n)) {
        son = son ^ vec[n];
      }
    }
    if (lon == son) ans++;
  }
  cout << ans << endl;
  return 0;
}
