#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<int> masks(M);
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    while (k--) {
      int v;
      cin >> v;
      masks[i] |= 1 << (v - 1);
    }
  }
  vector<bool> p(M);
  for (int i = 0; i < M; i++) {
    int b;
    cin >> b;
    p[i] = b;
  }
  long ans = 0;
  for (int x = 0; x < 1 << N; x++) {
    auto check = [](int y, int m, int p) {
      auto t = y & m;
      bool c = 0;
      while (t) {
        c ^= t & 1;
        t--;
      }
      return c == p;
    };
    int sum = 0;
    for (int i = 0; i < M; i++) {
      sum += check(x, masks[i], p[i]);
    }
    if (sum == M) ans++;
  }
  cout << ans << endl;
  return 0;
}
