#include <bits/stdc++.h>
int main() {
  int N, M;
  std::cin >> N >> M;
  std::vector<int> tests;
  for (int i = 0; i < M; i++) {
    int k;
    std::cin >> k;
    int test = 0;
    for (int i = 0; i < k; i++) {
      int s;
      std::cin >> s;
      test += (1 << s);
    }
    tests.push_back(test);
  }
  std::vector<int> accepts;
  for (int i = 0; i < M; i++) {
    int p;
    std::cin >> p;
    accepts.push_back(p);
  }
  const int patterns = (1 << N);
  int count = 0;
  for (int i = 0; i < patterns; i++) {
    bool ok = true;
    for (int j = 0; j < tests.size(); j++) {
      if (std::bitset<16>(tests[j] & i).count() % 2 != accepts[j]) {
        ok = false;
        break;
      }
    }
    if (ok) {
      count += 1;
    }
  }
  std::cout << count;
}
