#include <bits/stdc++.h>
using namespace std;
bool check(int *p, int *k, int **s, int m, int *l) {
  bool check = true;
  for (int i = 0; i < m; i++) {
    int sum = 0;
    for (int j = 0; j < k[i]; j++) {
      if (l[s[i][j]]) {
        sum++;
      }
    }
    if (sum % 2 != p[i]) {
      check = false;
      break;
    }
  }
  return check;
}
int main(void) {
  int n, m;
  cin >> n >> m;
  int k[m];
  int p[m];
  int **s = new int *[m];
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    s[i] = new int[k[i]];
    for (int j = 0; j < k[i]; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int sum = 0;
  int list[n];
  int pow = 1 << n;
  for (int i = 0; i < pow; i++) {
    for (int j = 0; j < n; j++) {
      list[j] = (i >> j) % 2;
    }
    if (check(p, k, s, m, list)) sum++;
  }
  cout << sum;
  return 0;
}
