#include <bits/stdc++.h>
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main() {
  long long int A, B, C, D, E, L, R, X, Y, W, H, N, M, K, sum = 0, num = 0,
                                                          flag = 0;
  string S, T;
  cin >> N >> M;
  vector<vector<int>> P(M, vector<int>(0, 0));
  vector<int> Q(M, 0);
  for (long long int i = 0; i < M; i++) {
    cin >> A;
    for (long long int j = 0; j < A; j++) {
      cin >> B;
      P[i].push_back(B);
    }
  }
  for (long long int i = 0; i < M; i++) cin >> Q[i];
  for (int bit = 0; bit < (1 << N); bit++) {
    flag = true;
    for (long long int i = 0; i < M; i++) {
      for (int q : P[i])
        if (bit & (1 << q)) num++;
      if (num % 2 != Q[i]) flag = false;
      num = 0;
    }
    if (flag) sum++;
  }
  cout << sum << endl;
}
