#include <bits/stdc++.h>
using namespace std;
long S[12][12];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  for (int m = 0; m < M; m++) {
    int K;
    cin >> K;
    for (int k = 0; k < K; k++) {
      int s;
      cin >> s;
      S[m][s - 1] = 1;
    }
  }
  int P[M];
  for (int m = 0; m < M; m++) {
    cin >> P[m];
  }
  long num, ans;
  num = pow(2, N);
  ans = 0;
  for (long i = 0; i <= num; i++) {
    bool ok = true;
    for (int m = 0; m < M; m++) {
      long count;
      count = 0;
      for (int s = 0; s < N; s++) {
        if ((S[m][s] == 1) && (((long)pow(2, s) & i) != 0)) count++;
      }
      if (count % 2 != P[m]) {
        ok = false;
        break;
      }
    }
    if (ok) ans++;
  }
  cout << ans << endl;
  return 0;
}
