#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;
}
int N, M;
vector<int> S[11];
bool P[11];
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--;
      S[m].push_back(s);
    }
  }
  for (int n = 0; n < N; n++) cin >> P[n];
  for (int n = 0; n < N; n++) all |= (1 << n);
  long long count = 0;
  for (long long T = 1; T <= all; T++) {
    bool inc = true;
    for (int m = 0; m < M; m++) {
      int count = 0;
      for (auto &&s : S[m]) {
        count += (T & (1 << s)) ? 1 : 0;
      }
      inc &= count % 2 == P[m];
    }
    count += inc;
  }
  cout << count << endl;
}
int main() {
  solve();
  return 0;
}
