#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int> > sw(M, vector<int>(0));
  int k[M];
  int temp;
  for (int i = 0; i < M; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> temp;
      sw[i].emplace_back(temp);
    }
  }
  int p[M];
  for (int i = 0; i < M; i++) cin >> p[i];
  int c = 0;
  int ok = 1;
  vector<int> on(N);
  int dec;
  int ans = 0;
  for (int i = 0; i < pow(2, N); i++) {
    ok = 1;
    dec = i;
    for (int j = 0; j < N; j++) {
      if (dec % 2 == 1)
        on[j] = j + 1;
      else
        on[j] = -1;
      dec /= 2;
    }
    for (int j = 0; j < M; j++) {
      c = 0;
      for (auto itr = sw[j].begin(); itr != sw[j].end(); ++itr) {
        if (find(on.begin(), on.end(), *itr) != on.end()) c++;
      }
      if (c % 2 != p[j]) {
        ok = 0;
        break;
      }
    }
    if (ok == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}
