#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const int MAX = 11;
int N, M;
vector<int> S[MAX], P(MAX, 0);
long long all = 0;
void solve() {
  cin >> N >> M;
  int k, s;
  for (int m = 0; m < M; m++) {
    cin >> k;
    for (int i = 0; i < k; i++) {
      cin >> s;
      S[m].push_back(s);
    }
  }
  for (int n = 0; n < N; n++) all |= (1 << n);
  for (int m = 0; m < M; m++) cin >> P[m];
  long long total = 0;
  for (long long T = 0; T <= all; T++) {
    bool allOn = true;
    for (int m = 0; m < M; m++) {
      int count = 0;
      for (auto &&s : S[m]) {
        count += (T >> s) & 1;
      }
      allOn &= count % 2 == P[m];
    }
    total += allOn;
  }
  cout << total << endl;
}
int main() {
  solve();
  return 0;
}
