#include <bits/stdc++.h>
using namespace std;
template <typename T>
void print(T x) {
  std::cout << x << " ";
}
template <typename T>
void println(T x) {
  std::cout << x << "\n";
}
signed main(void) {
  long long n, m;
  cin >> n >> m;
  vector<vector<long long>> s(m);
  for (long long i = 0; i < (m); i++) {
    long long k;
    cin >> k;
    for (long long j = 0; j < (k); j++) {
      long long si;
      cin >> si;
      s[i].push_back(si);
    }
  }
  vector<long long> p;
  for (long long i = 0; i < (m); i++) {
    long long pi;
    cin >> pi;
    p.push_back(pi);
  }
  long long ans = 0;
  bool unmatch = false;
  for (long long bit = 0; bit < (1 << n); ++bit) {
    unmatch = false;
    for (long long i = 0; i < (m); i++) {
      long long on = 0;
      for (long long j = 0; j < (s[i].size()); j++) {
        if (bit & (1 << j)) on++;
      }
      if (on % 2 != p[i]) {
        unmatch = true;
        break;
      }
    }
    if (unmatch) continue;
    ans++;
  }
  print(ans);
}
