#include <bits/stdc++.h>
using namespace std;
int light[200010];
int p[200010];
int main() {
  int N, M;
  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;
      light[j] |= 1 << (s - 1);
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int i = 0; i < (1 << N); i++) {
    bool ok = true;
    for (int j = 0; j < M; j++) {
      ok &= __builtin_popcount(light[j] & i) % 2 == p[j];
    }
    ans += ok;
  }
  cout << ans << endl;
  return 0;
}
