#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> S(M);
  vector<int> P(M);
  for (int m = 0; m < M; ++m) {
    int K;
    cin >> K;
    for (int k = 0; k < K; k++) {
      int s;
      cin >> s;
      S[m].push_back(s);
    }
  }
  for (int n = 0; n < N; n++) cin >> P[n];
  int ans = 0;
  for (int ptn = 0; ptn < (1 << N); ptn++) {
    vector<int> S_cnt(M);
    for (int j = 0; j < N; j++) {
      if (ptn >> j & 1) {
        for (int m = 0; m < M; m++) {
          for (int k = 0; k < S[m].size(); k++) {
            if (S[m][k] == j + 1) S_cnt[m] += 1;
          }
        }
      }
    }
    for (int m = 0; m < M; m++) {
      int tmp = S_cnt[m] % 2;
      if (tmp != P[m]) break;
      if (m == M - 1) ans += 1;
    }
  }
  cout << ans << endl;
}
