#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void YN(bool b) { cout << (b ? "Yes" : "No") << endl; }
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return (gcd(b, a % b));
}
template <class T>
inline T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
inline bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  vector<long long> k(m), p(m);
  vector<set<long long>> s(m);
  for (long long i = 0; i < (m); ++i) {
    cin >> k[i];
    for (long long j = 0; j < (k[i]); ++j) {
      long long S;
      cin >> S;
      s[i].insert(S);
    }
  }
  for (long long i = 0; i < (m); ++i) cin >> p[i];
  long long ans = 0;
  for (long long bit = 0; bit < (1 << n); ++bit) {
    vector<long long> a(m, 0);
    for (long long i = 0; i < m; ++i) {
      if ((bit >> i) & 1) {
        for (long long j = 0; j < (m); ++j) {
          if (s[j].find(i + 1) != s[j].end()) {
            a[j]++;
          }
        }
      }
    }
    for (long long i = 0; i < (m); ++i) a[i] %= 2;
    bool flag = true;
    for (long long i = 0; i < (m); ++i)
      if (a[i] != p[i]) flag = false;
    ans += flag;
  }
  cout << (ans) << endl;
  return 0;
}
