#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1000000000000000;
template <class T>
inline bool chmin(T& first, T second) {
  if (first > second) {
    first = second;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& first, T second) {
  if (first < second) {
    first = second;
    return true;
  }
  return false;
}
vector<long long> pw2(62, 1);
vector<long long> pw10(19, 1);
int main() {
  {
    for (long long i = 1; i <= (61); i++) pw2[i] = 2 * pw2[i - 1];
  }
  {
    for (long long i = 1; i <= (18); i++) pw10[i] = 10 * pw10[i - 1];
  }
  long long N, M;
  cin >> N >> M;
  long long ans = 0;
  vector<long long> k(N, 0);
  vector<vector<long long> > s(M, vector<long long>(N, 0));
  for (long long i = 0; i < (M); i++) {
    cin >> k[i];
    for (long long j = 0; j < (k[i]); j++) cin >> s[i][j];
  }
  vector<long long> p(M, 0);
  for (long long i = 0; i < (M); i++) cin >> p[i];
  for (long long i = 0; i < (pw2[N]); i++) {
    vector<long long> BIT(N);
    long long tmps = i;
    for (long long i2 = (N)-1; i2 >= 0; i2--) {
      BIT[i2] = tmps / pw2[i2];
      tmps %= pw2[i2];
    }
    vector<long long> point(M, 0);
    for (long long j = 0; j < (N); j++) {
      if (BIT[j] == 0) {
      } else {
        for (long long l = 0; l < (k[j]); l++) {
          point[s[j][l] - 1]++;
        }
      }
    }
    bool check = true;
    for (long long j = 0; j < (M); j++) {
      if (point[j] % 2 != p[j]) check = false;
    }
    if (check) ans++;
  }
  cout << ans << endl;
}
