#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, M;
  cin >> N >> M;
  vector<vector<long long>> S(M);
  for (int i = 0; i < M; i++) {
    long long k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      long long tmp;
      cin >> tmp;
      tmp--;
      S[i].push_back(tmp);
    }
  }
  vector<long long> P;
  for (int i = 0; i < M; i++) {
    long long tmp;
    cin >> tmp;
    P.push_back(tmp);
  }
  long long ans = 0;
  long long ct = 0;
  for (int i = 0; i < (1 << N); i++) {
    ct = 0;
    for (int l = 0; l < M; l++) {
      for (int j = 0; j < S[l].size(); j++) {
        long long tmp = i;
        if ((tmp >> S[l][j]) & 1) ct++;
      }
      if (ct % 2 == P[l]) {
        if (l == M - 1)
          ans++;
        else
          continue;
      } else
        break;
    }
  }
  cout << ans << endl;
}
