#include <bits/stdc++.h>
int main(void) {
  int n_switch, n_bulb, i, j;
  scanf("%d%d", &n_switch, &n_bulb);
  int n_con_switch;
  int switch_no;
  int switch_con[n_switch];
  memset(switch_con, 0, n_switch * sizeof(int));
  for (i = 0; i < n_bulb; i++) {
    scanf("%d", &n_con_switch);
    for (j = 0; j < n_con_switch; j++) {
      scanf("%d", &switch_no);
      switch_no--;
      switch_con[switch_no] |= (1 << i);
    }
  }
  int p = 0, tmp_p;
  for (i = 0; i < n_bulb; i++) {
    scanf("%d", &tmp_p);
    p |= (tmp_p << i);
  }
  int ans = 0, bulb_st;
  for (i = 1; i < (1 << n_switch); i++) {
    bulb_st = 0;
    for (j = 0; j < n_switch; j++) {
      if (i >> j & 1) bulb_st ^= switch_con[j];
    }
    if (bulb_st == p) ans++;
  }
  printf("%d\n", ans);
  return EXIT_SUCCESS;
}
