#include <bits/stdc++.h>
using namespace std;
long long Set(long long N, long long pos) { return N = N | (1 << pos); }
long long reset(long long N, long long pos) { return N = N & ~(1 << pos); }
bool check(long long N, long long pos) { return (bool)(N & (1 << pos)); }
long long p[100];
vector<long long> v[100];
long long ans = 0;
long long n;
void call(long long at, long long mask) {
  if (at == n + 1) {
    long long cnt = 0;
    for (long long i = 1; i <= n; i++) {
      long long cnt2 = 0;
      for (auto xx : v[i]) {
        if (check(mask, xx)) cnt2++;
      }
      if (cnt2 % 2 == p[i]) cnt++;
    }
    if (cnt == n) ans++;
    return;
  }
  call(at + 1, Set(mask, at));
  call(at + 1, mask);
}
int32_t main() {
  long long m, k, num;
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) {
    cin >> k;
    for (long long j = 0; j < k; j++) {
      cin >> num;
      v[i].push_back(num);
    }
  }
  for (long long i = 1; i <= n; i++) {
    cin >> p[i];
  }
  call(1, 0);
  cout << ans << endl;
  return 0;
}
