#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, K, S;
  cin >> N >> M;
  vector<vector<int>> bulb(M);
  vector<int> re(M);
  for (int i = 0; i < M; i++) {
    cin >> K;
    for (int j = 0; j < K; j++) {
      cin >> S;
      S--;
      bulb[i].push_back(S);
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> re[i];
  }
  long long ans = 0;
  for (int bits = 1; bits < (1 << N); bits++) {
    bool ok = true;
    for (int i = 0; i < M; i++) {
      int sum = 0;
      for (auto v : bulb[i]) {
        if (bits & (1 << v)) ++sum;
      }
      if (sum % 2 != re[i]) ok = false;
    }
    if (ok) ans++;
  }
  cout << ans << endl;
}
