#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> light(M);
  for (int i = 0; i < M; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int a;
      cin >> a;
      light[i].push_back(a);
    }
  }
  vector<int> P(N);
  for (int i = 0; i < N; ++i) {
    cin >> P[i];
  }
  int ans = 0;
  for (int bit = 0; bit < (1 << N); ++bit) {
    int on = 0;
    for (int i = 0; i < M; ++i) {
      int cnt = 0;
      for (auto p : light[i]) {
        if (bit & (1 << p - 1)) ++cnt;
      }
      if (cnt % 2 == P[i]) ++on;
    }
    if (on == M) ++ans;
  }
  cout << ans << "\n";
  return 0;
}
