#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  vector<bitset<10>> lights(m);
  vector<long long> onoff(m);
  for (long long i = 0; i < m; i++) {
    int tmp;
    cin >> tmp;
    for (long long i = 0; i < tmp; i++) {
      long long a;
      cin >> a;
      lights[i] |= (1 << (a - 1));
    }
  }
  for (long long i = 0; i < m; i++) {
    long long a;
    cin >> a;
    onoff[i] = a;
  }
  long long sum = 0;
  for (long long s = 0; s < 1ll << n; s++) {
    bitset<10> sw(s);
    for (long long i = 0; i < m; i++) {
      auto tmp = sw & lights[i];
      if (tmp.count() % 2 != onoff[i]) {
        goto fail;
      }
    }
    sum++;
  fail:
    0;
  }
  cout << sum << endl;
  return 0;
}
