#include <bits/stdc++.h>
using namespace std;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if (a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}
template <class T>
inline bool changeMinimum(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool changeMaximum(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
T output(T answer) {
  cout << answer << endl;
  return 0;
}
int binary(int bina) {
  int ans = 0;
  for (int i = 0; bina > 0; i++) {
    ans = ans + (bina % 2) * pow(10, i);
    bina = bina / 2;
  }
  return ans;
}
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> k(10);
  vector<vector<int> > vvv(10, vector<int>(10));
  for (int i = 0; i < M; ++i) {
    cin >> k[i];
    for (int j = 0; j < k[i]; ++j) {
      cin >> vvv[i][j];
    }
  }
  vector<int> p(10, 0);
  for (int i = 0; i < M; ++i) {
    cin >> p[i];
  }
  vector<int> s(N);
  int ans = 0;
  for (int i = 0; i < (1 << N); i++) {
    int sum = 0;
    for (int j = 0; j < N; j++) {
      if (i >> j & 1)
        s[j] = 0;
      else
        s[j] = 1;
    }
    int count = 0;
    for (int l = 0; l < M; ++l) {
      for (int m = 0; m < k[l]; ++m) {
        sum += s[vvv[l][m]];
      }
      if (p[l] == (sum % 2)) {
        count += 1;
      }
    }
    if (count == N) {
      ans++;
    }
  }
  cout << ans << endl;
}
