#include <bits/stdc++.h>
using namespace std;
vector<pair<int, pair<string, int>>> rest;
int cmp(pair<int, pair<string, int>> A, pair<int, pair<string, int>> B) {
  pair<string, int> a = A.second;
  pair<string, int> b = B.second;
  if (a.first != b.first) {
    return lexicographical_compare(a.first.begin(), a.first.end(),
                                   b.first.begin(), b.first.end());
  }
  return a.second > b.second;
}
int n, m;
vector<vector<int>> S(10);
bool correct[10];
bool test(int x) {
  bool light[10];
  fill(light, light + 10, 0);
  for (int i = 0; i < n; i++) {
    if (x % 2) {
      for (auto j : S[i]) {
        light[j] ^= 1;
      }
    }
    x /= 2;
  }
  for (int i = 0; i < n; i++) {
    if (correct[i] != light[i]) {
      return 0;
    }
  }
  return 1;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int k1;
      cin >> k1;
      k1--;
      S[i].push_back(k1);
    }
  }
  for (int i = 0; i < n; i++) {
    cin >> correct[i];
  }
  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {
    ans += test(i);
  }
  cout << ans;
}
