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