#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<vector<int> > s;
  int k;
  vector<int> k_num;
  for (long j = 0; j < m; j++) {
    cin >> k;
    k_num.push_back(k);
    vector<int> tmp;
    for (long i = 0; i < k; i++) {
      int s_tmp;
      cin >> s_tmp;
      tmp.push_back(s_tmp);
    }
    s.push_back(tmp);
  }
  vector<int> p;
  for (long i = 0; i < m; i++) {
    int p_tmp;
    cin >> p_tmp;
    p.push_back(p_tmp);
  }
  long ans = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    for (int j = 0; j < m; j++) {
      int count = 0;
      for (int i = 0; i < k_num[i]; i++) {
        if (bit & 1 << (s[j][i] - 1)) {
          count++;
        }
      }
      if (!(count % 2 == p[j])) {
        goto nextbit;
      }
    }
    ans++;
  nextbit:
    continue;
  }
  cout << ans << endl;
}
