#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long f = 1, x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return f * x;
}
const long long inf = 0x3f3f3f3f;
long long n, m;
const long long maxn = 15;
long long a[maxn];
long long st[maxn];
long long solve(long long pos, long long bit) {
  if (pos > n) return ((__builtin_popcount(bit) & a[pos]) & 1) == st[pos];
  return solve(pos + 1, bit) + solve(pos + 1, bit | (1 << pos));
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (long long i = 1; i <= m; ++i) {
    long long k;
    cin >> k;
    long long bit = 0;
    long long tmp;
    for (long long j = 1; j <= k; ++j) {
      cin >> tmp;
      bit |= (1 << tmp);
    }
    a[i] = bit;
  }
  for (long long i = 1; i <= m; ++i) {
    cin >> st[i];
  }
  long long ans = solve(1, 0);
  cout << ans / 4 << endl;
}
