#include <bits/stdc++.h>
using namespace std;
long long min(long long x, long long y) { return (x < y ? x : y); }
long long max(long long x, long long y) { return (x > y ? x : y); }
int keta(long long x) {
  if (x < 10) {
    return 1;
  } else {
    return keta(x / 10) + 1;
  }
}
int keta_wa(long long x) {
  if (x < 10) {
    return x;
  } else {
    return keta_wa(x / 10) + x % 10;
  }
}
int ctoi(char c) { return ((c >= '0' && c <= '9') ? c - '0' : 0); }
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  return b ? gcd(b, a % b) : a;
}
long long lcm(long long a, long long b) {
  if (a < b) {
    swap(a, b);
  }
  return a * b / gcd(a, b);
}
int main() {
  long long N, M;
  cin >> N >> M;
  long long k[M];
  long long p[M];
  vector<long long> v[M];
  for (int i = 0, i_len = (M); i < i_len; ++i) {
    cin >> k[i];
    for (int j = 0, j_len = (k[i]); j < j_len; ++j) {
      long long s;
      cin >> s;
      v[i].push_back(s);
    }
  }
  for (int i = 0, i_len = (M); i < i_len; ++i) {
    cin >> p[i];
  }
  long long count = 0;
  for (long long tane = 0; tane < pow(2, N); tane++) {
    long long temp = tane;
    long long sw[N];
    for (int i = 0, i_len = (N); i < i_len; ++i) {
      sw[i] = temp % 2;
      temp /= 2;
    }
    long long denkyu[M];
    ;
    for (int i = 0, i_len = ((M)); i < i_len; ++i) {
      (denkyu)[i] = (0);
    };
    for (int i = 0, i_len = (M); i < i_len; ++i) {
      for (long long x : v[i]) {
        denkyu[i] += sw[x];
      }
    }
    long long on_count = 0;
    for (int i = 0, i_len = (M); i < i_len; ++i) {
      on_count += (denkyu[i] % 2 == p[i]);
    }
    if (on_count == M) count++;
  }
  cout << count;
}
