#include <bits/stdc++.h>
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  uint32_t N, M;
  std::cin >> N >> M;
  uint32_t SS[11];
  uint32_t S[11][11] = {{0}};
  for (uint32_t i = 0; i < M; i++) {
    uint32_t x;
    std::cin >> x;
    SS[i] = x;
    for (uint32_t j = 0; j < x; j++) {
      std::cin >> S[i][j];
      S[i][j]--;
    }
  }
  std::bitset<11> C;
  for (uint32_t i = 0; i < M; i++) {
    uint8_t s;
    std::cin >> s;
    if (s) {
      C.set(i);
    }
  }
  uint32_t ret = 0;
  for (uint32_t bit = 0; bit < (1 << N); bit++) {
    uint8_t o[11] = {0};
    for (uint32_t i = 0; i < N; i++) {
      if (bit & (1 << i)) {
        o[i] = 1;
      }
    }
    bool found = true;
    for (uint32_t i = 0; i < M; i++) {
      uint32_t x = 0;
      for (uint32_t j = 0; j < SS[i]; j++) {
        if (o[S[i][j]]) {
          x++;
        }
      }
      if (C[i] && x % 2 == 0) {
        found = false;
      } else if (!C[i] && x % 2 != 0) {
        found = false;
      }
    }
    if (found) {
      ret++;
    }
  }
  std::cout << ret << std::endl;
}
