#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m, k;
  cin >> n >> m;
  vector<int> p(m + 5);
  vector<vector<int>> suichi(m + 5);
  for (auto i = 0; i < m; i++) {
    cin >> k;
    for (auto j = 0; j < k; j++) {
      int s;
      cin >> s;
      suichi[i].push_back(s);
    }
  }
  for (auto i = 0; i < m; i++) {
    cin >> p[i];
  }
  long long sum = 0;
  for (int bit = 1; bit < (1 << n); bit++) {
    bool ok = true;
    for (int i = 0; i < m; i++) {
      long long count = 0;
      for (auto v : suichi[i]) {
        if (bit & (1 << (v - 1))) {
          count++;
        }
      }
      if (count % 2 != p[i]) {
        ok = false;
      }
    }
    if (ok) {
      sum++;
    }
  }
  cout << sum << endl;
  return 0;
}
