#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
vector<pair<long long, long long>> p;
set<pair<long long, long long>> q;
signed main() {
  long long n, m;
  cin >> n >> m;
  long long k[11];
  long long s[11][11];
  long long p[11];
  for (long long i = 0; i < (m); i++) {
    cin >> k[i];
    for (long long j = 0; j < (k[i]); j++) cin >> s[i][j];
  }
  for (long long i = 0; i < (m); i++) cin >> p[i];
  long long ans = 0;
  for (long long bit = 0; bit < (1LL << n); bit++) {
    long long f = 1;
    for (long long i = 0; i < (m); i++) {
      long long cnt = 0;
      for (long long j = 0; j < (k[i]); j++) {
        if (bit & (1LL << s[i][j])) cnt++;
      }
      if (cnt % 2 != p[i]) {
        f = 0;
        break;
      }
    }
    if (f) ans++;
  }
  cout << ans << endl;
  return 0;
}
