#include <bits/stdc++.h>
using namespace std;
const int inf = 1012345678;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int N, M;
bool sw[12];
int c[12][12];
int p[12];
int k[12];
int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> c[i][j];
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    bool f = true;
    for (int i = 0; i < N; i++) {
      sw[i] = false;
    }
    for (int i = 0; i < N; i++) {
      if (bit & 1 << i) sw[i] = true;
    }
    for (int i = 0; i < M; i++) {
      int num = 0;
      for (int j = 0; j < k[i]; j++) {
        if (sw[c[i][j]] - 1) num++;
      }
      if (num % 2 != p[i]) f = false;
    }
    if (f) ans++;
  }
  cout << ans << endl;
}
