#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> S[N], T(M);
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      S[i].push_back(s - 1);
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> T[i];
  }
  int sum = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    int ans = 0;
    for (int j = 0; j < M; j++) {
      int cnt = 0;
      for (int i = 0; i < S[j].size(); i++) {
        if (bit & (1 << S[j][i])) cnt++;
      }
      if (cnt % 2 == T[j]) ans++;
    }
    if (ans == M) sum++;
  }
  cout << sum << endl;
}
