#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<bitset<10>> vec(m);
  vector<int> k(m);
  vector<int> p(m);
  for (int i = 0; i < (int)(m); i++) {
    cin >> k.at(i);
    for (int j = 0; j < (int)(k.at(i)); j++) {
      int pos;
      cin >> pos;
      vec.at(i).set(pos, 1);
    }
  }
  for (int i = 0; i < (int)(m); i++) {
    cin >> p.at(i);
  }
  int sum = 0;
  for (int tmp = 0; tmp < (1 << n); tmp++) {
    bitset<10> cnt(tmp);
    for (int i = 0; i < (int)(m); i++) {
      int match = (vec.at(i) & cnt).count();
      if ((match % 2) != p.at(i)) {
        goto SKIP;
      }
    }
    sum += 1;
  SKIP:
    int alias;
  }
  cout << sum << endl;
}
