#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> S[M];
  int p[M];
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      S[i].push_back(s);
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  int ans = 0;
  int Q[M] = {0};
  for (int i = 0; i < (1 << N); i++) {
    for (int i = 0; i < M; i++) {
      Q[i] = 0;
    }
    bool OK = true;
    for (int j = 0; j < M; j++) {
        for (int k = 0; k < S[j].size(); k++) {
          if (i & (1 << S[j][k]-1)) {
              Q[S[j][k] - 1]++;
          }
        }
      }
    for (int j = 0; j < M; j++) {
      if (Q[j] % 2 != p[i]) {
        OK = false;
      }
    }
    if (OK) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}