#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<vector<int> > S;
vector<int> P;
int main() {
  cin >> n >> m;
  S.resize(m);
  P.resize(m);
  for (int i = 0; i < (m); ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < (k); ++j) {
      int s;
      cin >> s;
      s--;
      S[j].push_back(s);
    }
  }
  for (int i = 0; i < (m); ++i) cin >> P[i];
  int ans = 0;
  for (int bit = 0; bit < (1 << n); ++bit) {
    bool ok = true;
    for (int i = 0; i < (m); ++i) {
      int count = 0;
      for (auto x : S[i]) {
        if (bit & (1 << x)) count++;
      }
      if (count % 2 != P[i]) {
        ok = false;
        break;
      }
    }
    if (ok) ans++;
  }
  cout << ans << endl;
  return 0;
}
