#include <bits/stdc++.h>
using namespace std;
int N, M;
int Bcount(int bit, int n) {
  int count = 0;
  for (int i = 0; i < (n); ++i) {
    if (bit & (1 << i)) {
      count++;
    }
  }
  return count;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> M;
  int Mask[10] = {0};
  int P[10];
  int num;
  for (int i = 0; i < (M); ++i) {
    cin >> num;
    for (int j = 0; j < (num); ++j) {
      int tmp;
      cin >> tmp;
      Mask[i] += (1 << tmp - 1);
    }
  }
  for (int i = 0; i < (M); ++i) {
    cin >> P[i];
  }
  int ans = 0;
  for (int bit = 0; bit < (1 << N); ++bit) {
    ans++;
    for (int i = 0; i < (M); ++i) {
      int tmp = (Mask[i] & bit);
      int c = Bcount(tmp, M);
      if (c % 2 != P[i]) {
        ans--;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
