#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m;
  cin >> n >> m;
  long long a[101];
  memset(a, 0, sizeof(a));
  long long p[101];
  memset(p, 0, sizeof(p));
  for (long long i = 0; i < m; i++) {
    long long k;
    cin >> k;
    for (long long j = 1; j <= k; j++) {
      long long x;
      cin >> x;
      x--;
      a[x] |= (1 << i);
    }
  }
  long long k = 0;
  for (long long i = m - 1; i >= 0; i--) {
    cin >> p[i];
    if (p[i]) {
      k |= (1 << i);
    }
  }
  long long ans = 0;
  for (long long i = 0; i <= (1 << n); i++) {
    long long num = 0;
    for (long long j = 0; j < n; j++) {
      if (i & (1 << j)) continue;
      num ^= a[j];
    }
    if (num == k) ans++;
  }
  cout << ans << endl;
  return 0;
}
