#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m;
  int k[10], s[10][10];
  int p[10];
  cin >> n >> m;
  for (int i = 0; i < (m); ++i) {
    cin >> k[i];
    for (int j = 0; j < (k[i]); ++j) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < (m); ++i) cin >> p[i];
  int cnt = 0;
  int alllight = 0;
  int ans = 0;
  int sw[10] = {};
  for (int bit = 0; bit < (1 << n); ++bit) {
    for (int i = 0; i < n; ++i) {
      if (bit & (1 << i)) sw[i] = 1;
    }
    alllight = 0;
    for (int j = 0; j < (m); ++j) {
      cnt = 0;
      for (int x = 0; x < (k[j]); ++x) {
        if (sw[k[x]] == 1) cnt++;
      }
      if (cnt % 2 == p[j]) alllight++;
    }
    if (alllight == m) ans++;
    for (int i = 0; i < (n); ++i) sw[i] = 0;
  }
  cout << ans << endl;
}
