#include <bits/stdc++.h>
using namespace std;
int N, M;
int bulb[11];
int p[11];
int countbit(int v) {
  unsigned int c;
  for (c = 0; v; c++) v &= v - 1;
  return c;
}
int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      bulb[i] |= (1 << s);
    }
  }
  for (int i = 0; i < M; i++) cin >> p[i];
  int ans = 0;
  for (int i = 0; i < (1 << N); i += 2) {
    bool success = true;
    for (int j = 0; j < M; j++)
      if (countbit(bulb[j] & i) % 2 != p[j]) success = false;
    ans += success;
  }
  cout << ans;
}
