#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const double EPS = 1e-10;
using ll = long long;
using P = pair<int, int>;
template <class T = int>
using V = vector<T>;
template <class T>
bool inline chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool inline chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T = int>
T inline input() {
  T x;
  cin >> x;
  return (x);
}
template <class T>
void inline print(T& x) {
  cout << x << '\n';
}
const int dxs[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dys[] = {0, -1, 0, 1, 1, -1, -1, 1};
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  int K[M];
  V<int> S[M];
  for (int i = 0; i < (M); i++) {
    cin >> K[i];
    for (int j = 0; j < (K[i]); j++) {
      int s;
      cin >> s;
      S[i].push_back(s);
    }
  }
  int P[M];
  for (int i = 0; i < (M); i++) cin >> P[i];
  int max = 1;
  for (int i = 0; i < (N); i++) max *= 2;
  int ans = 0;
  for (int n = 0; n < (max); n++) {
    int s[N];
    int x = n;
    for (int i = 0; i < (N); i++) {
      s[i] = x & 1;
      x >>= 1;
    }
    int sum = 0;
    auto isOK = [&](int* s) {
      for (int i = 0; i < (M); i++) {
        for (int j = 0; j < (K[i]); j++) sum += s[S[i][j] - 1];
        if (sum % 2 != P[i]) return false;
      }
      return true;
    };
    if (isOK(s)) ans++;
  }
  cout << ans << endl;
  return 0;
}
