#include <bits/stdc++.h>
using namespace std;
template <class T>
void chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
}
template <class T>
void chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
}
void YesNo(long long a) { cout << ((a) ? "Yes" : "No") << "\n"; }
void YESNO(long long a) { cout << ((a) ? "YES" : "NO") << "\n"; }
void AorB(long long a, string b, string c) { cout << ((a) ? b : c) << "\n"; }
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
void start() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
}
signed main() {
  start();
  long long n, m;
  cin >> n >> m;
  vector<long long> p(m);
  vector<vector<long long> > s(n);
  for (long long i = 0; i < m; ++i) {
    long long t;
    cin >> t;
    for (long long j = 0; j < t; ++j) {
      long long t1;
      cin >> t1;
      t1--;
      s[t1].push_back(j);
    }
  }
  for (long long i = 0; i < m; ++i) cin >> p[i];
  long long ans = 0;
  long long k = 1;
  k <<= n;
  for (long long i = 0; i < k; ++i) {
    vector<long long> light(m);
    for (long long mask = 1; mask < k; mask <<= 1) {
      if (i & mask) {
        long long l = log2(mask);
        for (long long j = 0; j < s[l].size(); ++j) light[s[l][j]]++;
      }
    }
    long long check = 0;
    for (long long j = 0; j < m; ++j)
      if (light[j] % 2 == p[j]) check++;
    if (check == m) ans++;
  }
  cout << ans << "\n";
  return 0;
}
