#include <bits/stdc++.h>
int main(int argc, const char* argv[]) {
  int n;
  scanf("%d", &n);
  int m;
  scanf("%d", &m);
  std::map<int, std::set<int>> map;
  for (int i = 0; i < m; i++) {
    int k;
    scanf("%d", &k);
    std::set<int> set;
    for (int j = 0; j < k; j++) {
      int x;
      scanf("%d", &x);
      set.insert(x);
    }
    map[i] = set;
  }
  std::vector<bool> p;
  for (int i = 0; i < m; i++) {
    int x;
    scanf("%d", &x);
    p.push_back(x);
  }
  int count = 0;
  for (int i = 0; i < std::pow(2, n); i++) {
    bool on = true;
    for (int j = 0; j < m; j++) {
      bool sw = false;
      for (int k : map.at(j)) {
        sw = sw ^ ((i & (int)std::pow(2, k)) != 0);
      }
      if (sw != p.at(j)) on = false;
    }
    if (on) count++;
  }
  printf("%d\n", count);
  return 0;
}
