#include <bits/stdc++.h>
using namespace std;
long long p[11];
bool check(long long a, vector<long long> b, long long c) {
  long long cnt = 0;
  for (auto i : b) {
    if (a & (1 << i)) cnt++;
  }
  if (cnt % 2 == p[c])
    return true;
  else
    return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    long long k[m];
    vector<long long> v[m];
    for (long long i = 0; i < m; i++) {
      cin >> k[i];
      for (long long j = 0; j < k[i]; j++) {
        long long a;
        cin >> a;
        v[i].push_back(a - 1);
      }
    }
    for (long long i = 0; i < m; i++) cin >> p[i];
    long long ans = 0;
    for (long long i = 1; i < (long long)pow(2, n); i++) {
      long long cnt = 0;
      for (long long j = 0; j < m; j++) {
        if (check(i, v[j], j) == true) cnt++;
      }
      if (cnt == m) ans++;
    }
    cout << ans;
  }
  return 0;
}
