#include <bits/stdc++.h>
int main() {
  int n, m, k[11], s[11][11], p[11];
  scanf("%d%d", &n, &m);
  for (int i = 0; i < (m); ++i) {
    scanf("%d", &k[i]);
    for (int j = 0; j < (k[i]); ++j) {
      scanf("%d", &s[i][j]);
    }
  }
  for (int i = 0; i < (m); ++i) {
    scanf("%d", &p[i]);
  }
  int on[11], times = 0;
  for (int x = 0; x < (1 << n); ++x) {
    for (int i = 0; i < (m); ++i) {
      for (int j = 0; j < (m); ++j) {
        if (x == s[i][j]) {
          on[i]++;
        }
      }
    }
    bool ok = true;
    for (int i = 0; i < (m); ++i) {
      if (((on[i]) % 2) != p[i]) {
        ok = false;
        break;
      }
    }
    if (ok == true) times++;
  }
  printf("%d\n", times);
  return 0;
}
