#include <bits/stdc++.h>
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;
}
using namespace std;
const int mod = 1e9 + 7;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> connect(n);
  vector<int> p(m);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    connect[i].resize(k);
    for (int j = 0; j < k; j++) {
      cin >> connect[i][j];
      connect[i][j]--;
    }
  }
  for (int i = 0; i < m; i++) cin >> p[i];
  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {
    bool ok = true;
    for (int j = 0; j < m; j++) {
      int count = 0;
      for (int id : connect[j]) {
        if ((i >> id) & 1) count++;
      }
      count %= 2;
      if (count != p[j]) ok = false;
    }
    if (ok == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}
