#include <bits/stdc++.h>
using namespace std;
constexpr int Inf = 1000000001;
constexpr long long INF = 1e18;
constexpr long long MOD = 998244353;
const double PI = 3.1415926535897;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> S[20];
  for (int i = 0; i < M; i++) {
    int A;
    cin >> A;
    for (int i = 0; i < A; i++) {
      int B;
      cin >> B;
      S[B - 1].push_back(i);
    }
  }
  vector<int> vec(M);
  for (int i = 0; i < M; i++) {
    cin >> vec.at(i);
  }
  int ret = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    vector<bool> on;
    for (int i = 0; i < N; i++) {
      if (bit & (1 << i)) {
        on.push_back(i);
      }
    }
    vector<int> cnt(M);
    for (int i = 0; i < on.size(); i++) {
      for (int j = 0; j < S[on.at(i)].size(); j++) {
        cnt.at(S[on.at(i)].at(j))++;
      }
    }
    bool ret2 = true;
    for (int i = 0; i < M; i++) {
      if (cnt.at(i) % 2 != vec.at(i)) {
        ret2 = false;
      }
    }
    if (ret2 == true) {
      ret++;
    }
  }
  cout << ret << endl;
}
