#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int k;
  int s;
  std::vector<int> mask(M, 0);
  std::vector<int> p(M);
  for (int i = 0; i < M; i++) {
    cin >> k;
    for (int j = 0; j < k; j++) {
      cin >> s;
      mask.at(i) |= (1 << s);
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> p.at(i);
  }
  int jogen = pow(2, N);
  int count = 0;
  for (int i = 1; i < jogen; i++) {
    bool flag = true;
    for (int j = 0; j < M; j++) {
      int light = __builtin_popcount((i << 1) & mask.at(j));
      if (light % 2 != p.at(j)) {
        flag = false;
        break;
      }
    }
    count += flag;
  }
  cout << count << endl;
}
