#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const int INT_INF = 1e9;
const long long MOD = 1e9 + 7;
template <class T>
void puts(T x) {
  std::cout << x << std::endl;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
using namespace std;
int N, M;
int k[11];
int s[11][11];
int p[11];
int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int comb = 0; comb < (1 << N); comb++) {
    int sum_of_on_bulb = 0;
    for (int j = 0; j < M; j++) {
      int sum_of_on_switch = 0;
      for (int l = 0; l < M; l++) {
        if (comb & (1 << s[j][l])) sum_of_on_switch++;
      }
      if (sum_of_on_switch % 2 == p[j]) sum_of_on_bulb++;
    }
    if (sum_of_on_bulb == M) ans++;
  }
  cout << ans << endl;
}
