#include <bits/stdc++.h>
using ll = long long;
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;
}
int n, m, k[10];
int p[10];
vector<int> s[10];
int main() {
  int st;
  cin >> n >> m;
  for (int i = 0; i < (int)(m); i++) {
    cin >> k[i];
    for (int j = 0; j < (int)(k[i]); j++) {
      cin >> st;
      s[i].push_back(st - 1);
    }
  }
  int ans = 0;
  for (int i = 0; i < (int)(m); i++) cin >> p[i];
  for (int i = 0; i < (int)(1 << n); i++) {
    vector<int> dp(n);
    int onN = 0;
    for (int j = 0; j < (int)(n); j++) {
      dp[j] = (i >> j) & 1 == 1;
    }
    for (int j = 0; j < (int)(m); j++) {
      int on = 0;
      for (int l = 0; l < (int)(s[j].size()); l++) {
        on += dp[l];
      }
      if (on % 2 == p[j]) onN++;
    }
    if (onN == m) {
      ans++;
    }
  }
  cout << ans << endl;
}
