#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  int ans = 0;
  cin >> N >> M;
  vector<int> k(M);
  vector<int> p(M);
  vector<vector<int>> s(M, vector<int>(N));
  for (int i = 0; i < M; i++) {
    cin >> 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 bit = 0; bit < (1 << N); ++bit) {
    vector<int> ss(M);
    for (int i = 0; i < N; ++i) {
      if (bit & (1 << i)) {
        for (int i_k = 0; i_k < M; ++i_k) {
          for (int i_s = 0; i_s < k[i_k]; ++i_s) {
            if (s[i_k][i_s] = i) {
              ss[i_k]++;
            }
          }
        }
      }
    }
    int tmpcnt = 0;
    for (int i_ = 0; i_ < M; ++i_) {
      if (ss[i_] % 2 == p[i_]) {
        tmpcnt++;
      }
    }
    if (tmpcnt == M) {
      cnt++;
    }
  }
  cout << cnt / 2 << endl;
}
