#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, M, ss, num, ans;
  ans = 0;
  num = 0;
  cin >> N >> M;
  vector<long long int> K(M), P(M);
  vector<vector<int> > s(M);
  for (int i = 0; i < M; i++) {
    cin >> K[i];
    for (int j = 0; j < K[i]; j++) {
      cin >> ss;
      s[i].push_back(ss);
    }
  }
  for (int i = 0; i < M; i++) cin >> P[i];
  for (int i = 0; i < pow(2, N); i++) {
    int num = 0;
    if (i == 0) {
      for (int j = 0; j < M; j++) {
        if (P[j] == '0') num++;
      }
    } else {
      for (int k = 0; k < M; k++) {
        int cou = 0;
        for (int j = 0; j < N; j++) {
          if (i & (1 << j)) {
            for (int l = 0; l < K[k]; l++) {
              if (s[k][l] == j + 1) cou++;
            }
          }
        }
        if (P[k] == cou % 2) num++;
      }
    }
    if (num == M) ans++;
  }
  cout << ans << endl;
}
