#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> switches(N, 0);
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      s--;
      switches[s] |= 1 << i;
    }
  }
  int cnt = 0;
  int p = 0;
  for (int i = 0; i < M; i++) {
    int q = 0;
    cin >> q;
    p |= 1 << i;
  }
  for (int i = 0; i < (1 << N); i++) {
    int l = 0;
    for (int j = 0; j < N; j++) {
      if ((i >> j) & 1) {
        l ^= switches[j];
      }
    }
    if (l == p) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
