#include <bits/stdc++.h>
using namespace std;
const long long LINF = 1e18;
const int INF = 1e9;
template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
using Graph = vector<vector<long long>>;
const long long MOD = 1000000007;
const double PI = 3.1415926535897932;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  vector<long long> k(m);
  vector<vector<long long>> s(m, vector<long long>());
  vector<long long> p(m);
  for (long long i = 0; i < (m); i++) {
    cin >> k[i];
    for (long long j = 0; j < (k[i]); j++) {
      long long tmp;
      cin >> tmp;
      s[i].push_back(tmp);
    }
  }
  for (long long i = 0; i < (m); i++) cin >> p[i];
  long long ans = 0;
  long long bits = (1 << n) - 1;
  while (bits) {
    bool ok = true;
    long long tmp = bits;
    for (int i = 0; i < m; i++) {
      long long sum = 0;
      for (int j = 0; j < s[i].size(); j++) {
        if ((tmp >> (s[i][j] - 1)) & 1) {
          sum++;
        }
      }
      if (sum % 2 != p[i]) ok = false;
    }
    if (ok) ans++;
    bits--;
  }
  cout << ans << endl;
  return 0;
}
