#include <bits/stdc++.h>
using namespace std;
const long long INF = 1ll << 60;
const long double EPS = 1e-10;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template <class T>
inline void amax(T &a, const T &b) {
  if (a < b) a = b;
}
template <class T>
inline void amin(T &a, const T &b) {
  if (a > b) a = b;
}
signed main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  long long k[M];
  vector<vector<long long> > s(M);
  for (long long i = (long long)0; i < M; i++) {
    scanf("%lld", &k[i]);
    for (long long j = (long long)0; j < k[i]; j++) {
      long long t;
      scanf("%lld", &t);
      s[i].insert(s[i].end(), --t);
    }
  }
  long long p[M];
  for (long long i = (long long)0; i < sizeof(p) / sizeof(long long); i++)
    scanf("%lld", p + i);
  int cnt = 0;
  bool dame = false;
  long long ans = 0;
  long long x = 0;
  long long b = (1 << N) - 1;
  for (long long i = (long long)0; i < b; i++) {
    for (long long l = (long long)0; l < M; l++) {
      cnt = 0;
      for (long long a = (long long)0; a < k[l]; a++) {
        long long temp = s[l][a];
        x = i;
        if ((x >> temp) & 1) cnt++;
      }
      if ((cnt % 2) != p[l]) dame = true;
    }
    if (!dame) ans++;
    dame = false;
  }
  printf("%lld\n", ans);
}
