#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<string> vec(m);
  for (long long i = 0; i < (m); i++) {
    int k;
    cin >> k;
    string t = "";
    map<int, int> mp;
    for (long long j = 0; j < (k); j++) {
      int s;
      cin >> s;
      s--;
      mp[s]++;
    }
    for (long long j = 0; j < (n); j++) {
      if (!mp[j])
        t += '0';
      else
        t += '1';
    }
    vec[i] = t;
  }
  vector<int> p(m);
  for (long long i = 0; i < (m); i++) cin >> p[i];
  int ans = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    int sum = 0;
    for (long long j = 0; j < (m); j++) {
      int s = stoi(vec[j]);
      if (__builtin_popcount(bit & s) % 2 == p[j]) sum++;
    }
    if (sum == m) ans++;
  }
  cout << ans << endl;
}
