#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
int const INF = 1001001001;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<vector<int> > S(M);
  for (int i = 0; i < (M); ++i) {
    int k;
    cin >> k;
    for (int i = 0; i < (k); ++i) {
      int s;
      cin >> s;
      --s;
      S[i].push_back(s);
    }
  }
  vector<int> P(M);
  for (int i = 0; i < (M); ++i) cin >> P[i];
  int ans = 0;
  for (int bit = 0; bit << (1 << N); ++bit) {
    bool ok = true;
    for (int i = 0; i < (M); ++i) {
      int cnt = 0;
      for (auto s : S[i]) {
        if (bit & (1 << s)) cnt++;
      }
      if (cnt % 2 != P[i]) ok = false;
    }
    if (ok) ++ans;
  }
  cout << ans << endl;
  return 0;
}
