#include <bits/stdc++.h>
using namespace std;
int bitCount(uint bits) {
  int cnt = 0;
  while (bits != 0) {
    ++cnt;
    bits &= bits - 1;
  }
  return cnt;
}
int main() {
  uint a[10], p[10];
  uint n, m, k, t;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> k;
    for (; k > 0; k--) {
      cin >> t;
      a[i] |= 1 << (t - 1);
    }
  }
  for (int i = 0; i < m; i++) cin >> p[i];
  int cnt = 0;
  for (t = 0; t < (1 << n); t++) {
    bool ok = true;
    for (int i = 0; i < m; i++) {
      if (bitCount(a[i] & t) % 2 != p[i]) {
        ok = false;
        break;
      }
    }
    if (ok) cnt++;
  }
  cout << cnt << endl;
}
