#include <bits/stdc++.h>
using namespace std;
int main() {
  int bit, i, j, M, N;
  int number[10], switches[10][10], onoff[10];
  int ultimatesum = 0;
  cin >> N >> M;
  for (i = 0; i < M; i++) {
    cin >> number[i];
    for (j = 0; j < number[i]; j++) scanf("%d", &switches[i][j]);
  }
  for (i = 0; i < M; i++) cin >> onoff[i];
  for (bit = 0; bit < pow(2.0, double(M)); bit++) {
    for (i = 0; i < M; i++) {
      int somesum1 = 0;
      for (j = 0; j < number[i]; j++) {
        int somesum2 = (bit >> (switches[i][j] - 1)) % 2;
        somesum1 += somesum2;
      }
      if (somesum1 % 2 != onoff[i]) break;
    }
    if (i == M) ultimatesum++;
  }
  cout << ultimatesum << endl;
  return 0;
}
