#include <bits/stdc++.h>
using namespace std;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if (a < b) euclidean_gcd(b, a);
  unsigned r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}
long long int input() {
  long long int a;
  cin >> a;
  return a;
}
long long int n, m;
long long int a[20][20] = {0};
long long int q[20];
bool p[20];
int sub(int s1, bool s2, bool s3[]) {
  bool b[20];
  for (int i = 0; i < m; i++) {
    b[i] = a[s1][i] && s2 ? !s3[i] : s3[i];
  }
  if (s1 == n - 1) {
    for (int i = 0; i < m; i++)
      if (b[i] % 2 != p[i]) return 0;
    return 1;
  }
  s1++;
  return sub(s1, 0, b) + sub(s1, 1, b);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> q[i];
    for (int j = 0; j < q[i]; j++) a[j][input() - 1] = 1;
  }
  for (int i = 0; i < m; i++) cin >> p[i];
  bool b[20];
  cout << sub(0, 0, b) + sub(0, 1, b) << endl;
}
