#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(N);
  int ans = 0;
  int p = 0;
  for (int i = 0; i < M; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int s;
      cin >> s;
      s--;
      a[s] |= 1 << i;
    }
  }
  for (int i = 0; i < M; ++i) {
    int x;
    cin >> x;
    p |= x << i;
  }
  int t = 0;
  for (int i = 0; i < 1 << N; ++i) {
    for (int j = 0; j < N; ++j) {
      if (i >> j & 1) {
        t ^= a[j];
      }
    }
    if (t == p) ans++;
  }
  cout << ans << endl;
}
