#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> k(m);
  vector<vector<int> > s;
  vector<int> p(m);
  s.resize(m);
  int ans = 0;
  for (int i = 0; i < (m); ++i) {
    cin >> k[i];
    s[i].resize(k[i]);
    for (int j = 0; j < (k[i]); ++j) cin >> s[i][j];
  }
  for (int i = 0; i < (m); ++i) cin >> p[i];
  for (int bit = 0; bit < ((1 << n)); ++bit) {
    bool ok = true;
    for (int i = 0; i < (m); ++i) {
      int cnt = 0;
      for (auto on : s[i]) {
        if (bit & (1 << on)) cnt++;
      }
      if (cnt % 2 != p[i]) ok = false;
    }
    if (ok) ans++;
  }
  cout << ans << endl;
}
