#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> k(M), p(M);
  vector<vector<int> > s(M);
  for (int i = 0; i < M; i++) {
    cin >> k[i];
    s[i] = vector<int>(k[i]);
    for (int j = 0; j < k[i]; j++) cin >> s[i][j];
  }
  for (int i = 0; i < M; i++) cin >> p[i];
  int cnt = 0;
  for (int i = 0; i < pow(2, N); i++) {
    vector<int> on(N);
    int flag = 1;
    for (int j = 0; j < N; j++) {
      on[j] = (i >> j) & 1;
    }
    for (int j = 0; j < M; j++) {
      int onn = 0;
      for (int l = 0; l < k[j]; l++) {
        onn += on[s[j][l]];
      }
      if (onn % 2 != p[j]) flag = 0;
    }
    if (flag == 1) cnt++;
  }
  cout << cnt;
  return 0;
}
