#include <bits/stdc++.h>
using namespace std;
int numofbits(int bits);
int main(void) {
  int N, M;
  cin >> N >> M;
  int k[10], s[10][10];
  int mask[10];
  for (int i = 0; i < M; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> s[i][j];
      mask[i] |= s[i][j];
    }
  }
  int p[10];
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  int c = 0, t = pow(2, N);
  for (int i = 0; i < t; i++) {
    bool f = true;
    for (int j = 0; j < M; j++) {
      f = f && (numofbits(i & mask[j]) % 2 == p[j]);
    }
    if (f) c++;
  }
  cout << c << endl;
}
int numofbits(int bits) {
  int num = 0;
  for (; bits != 0; bits &= bits - 1) {
    num++;
  }
  return num;
}
