#include <bits/stdc++.h>
using namespace std;
void check(int &ans, int N, int &M, vector<int> sw, vector<vector<int>> &vec,
           vector<int> &p) {
  if (N == 0) {
    vector<int> s(sw.size());
    for (int i = 0; i < sw.size(); i++) s[i] = sw[i];
    bool x = true;
    for (int i = 0; i < M; i++) {
      int y;
      for (int j = 0; j < vec[i].size(); j++) {
        y += s[vec[i][j] - 1];
      }
      if (y % 2 != p[i]) {
        x = false;
        break;
      }
    }
    if (x) {
      ans++;
    }
    return;
  }
  check(ans, N - 1, M, sw, vec, p);
  sw[N - 1] = (sw[N - 1] + 1) % 2;
  check(ans, N - 1, M, sw, vec, p);
}
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> vec(M);
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    vec[i].resize(k);
    for (int j = 0; j < k; j++) {
      cin >> vec[i][j];
    }
  }
  vector<int> p(M);
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  int ans = 0;
  vector<int> sw(N, 0);
  check(ans, N, M, sw, vec, p);
  cout << ans;
}
