#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int main() {
  int N, M;
  cin >> N >> M;
  int k[10], s[10][10], p[10];
  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];
  long long ans = 0;
  for (int x = 0; x < (1 << N); x++) {
    vector<int> S(N, 0);
    for (int i = 0; i < N; i++) {
      if (x & (1 << i)) S[i] = 1;
    }
    int ok = 0;
    int cnt = 0;
    for (int i = 0; i < M; i++) {
      for (int j = 0; j < k[i]; j++) {
        if (S[s[i][j] - 1] == 1) cnt++;
      }
      if (cnt % 2 == p[i]) ok++;
    }
    if (ok == M) {
      ans++;
    }
  }
  cout << ans << endl;
}
