#include <bits/stdc++.h>
using namespace std;
void fsscan() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
void scani(int &x) {
  register int c = getchar();
  x = 0;
  int neg = 0;
  for (; ((c < 48 || c > 57) && c != '-'); c = getchar())
    ;
  if (c == '-') {
    neg = 1;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (neg) x = -x;
}
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
vector<int> decToBinary(int n, int l) {
  vector<int> v(l, 0);
  int i = 0;
  while (n > 0) {
    v[i] = (n % 2);
    n = n / 2;
    i++;
  }
  reverse(v.begin(), v.end());
  return v;
}
int main() {
  fsscan();
  int n, m;
  cin >> n >> m;
  vector<int> bulbs[m];
  for (int i = 0; i < m; i++) {
    int s;
    cin >> s;
    while (s--) {
      int x;
      cin >> x;
      bulbs[i].push_back(x);
    }
  }
  int p[m];
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int s = 0;
  for (int i = 0; i <= pow(2, n); i++) {
    vector<int> v = decToBinary(i, n);
    int c = 0;
    for (int j = 0; j < m; j++) {
      int count = 0;
      for (int k = 0; k < bulbs[j].size(); k++) {
        int index_val = bulbs[j][k];
        count += v[index_val - 1];
      }
      if (count % 2 == p[j]) c++;
    }
    if (c == m) s++;
  }
  cout << s;
  return 0;
}
