#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  vector<int> k(m);
  vector<vector<int> > s(m, vector<int>(10));
  vector<int> a(n);
  vector<int> p(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 ans = 0;
  int r = 10;
  for (int bit = 0; bit < (1 << r); ++bit) {
    for (int i = 0; i < r; i++) {
      if (bit & (1 << i)) {
        a[i] = 1;
      }
    }
    bool x = true;
    for (int i = 0; i < (m); ++i) {
      int count = 0;
      for (int j = 0; j < (k[i]); ++j) {
        if (a[s[i][j] - 1] == 1) count++;
      }
      if (count % 2 != p[i]) {
        x = false;
        break;
      }
    }
    if (x == true) ans++;
    for (int i = 0; i < (n); ++i) a[i] = 0;
  }
  cout << ans;
  return 0;
}
