#include <bits/stdc++.h>
using namespace std;
const static unsigned long long INVALID_DIGIT = ~(unsigned long long)0;
int main() {
  unsigned long long N, M;
  cin >> N >> M;
  struct Light {
    std::vector<int> switches;
    int p;
  };
  std::vector<Light> lights(M);
  for (size_t i = 0; i < M; i++) {
    int k;
    cin >> k;
    lights[i].switches.resize(k);
    for (int switchI = 0; switchI < k; switchI++) {
      cin >> lights[i].switches[switchI];
      lights[i].switches[switchI]--;
    }
  }
  for (size_t i = 0; i < M; i++) {
    int p;
    cin >> p;
    lights[i].p = p;
  }
  int successCount = 0;
  int lightOnOffBits = 0;
  int maxValue = 1 << N;
  while (lightOnOffBits <= maxValue) {
    bool success = true;
    for (const auto &light : lights) {
      int onCount = 0;
      for (auto switchIdx : light.switches) {
        onCount += ((lightOnOffBits >> switchIdx) & 0x01) == 1;
      }
      if (onCount % 2 != light.p) {
        success = false;
        break;
      }
    }
    if (success) {
      successCount++;
    }
    lightOnOffBits++;
  }
  cout << successCount << endl;
  return 0;
}
