#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const long long LINF = 1LL << 60;
const long long MOD = 1e9 + 7;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
bool rel[13][13];
int p[13];
int onoff[13];
int n, m;
bool judge() {
  bool ret = true;
  for (int i = (1); i <= (m); i++) {
    int now = 0;
    for (int j = (1); j <= (n); j++) {
      if (rel[i][j] == true) {
        now += onoff[j];
      }
    }
    if (now % 2 != p[i]) {
      return false;
    }
  }
  return ret;
}
int main() {
  cin >> n >> m;
  for (int i = (1); i <= (m); i++) {
    int k;
    cin >> k;
    for (int j = (1); j <= (k); j++) {
      int s;
      cin >> s;
      rel[i][s] = true;
    }
  }
  for (int i = (1); i <= (m); i++) {
    cin >> p[i];
  }
  int ret = 0;
  for (int i = (0); i <= ((1 << n)); i++) {
    int cur = (i << 1);
    for (int j = (1); j <= (n); j++) {
      if (cur & (1 << j)) {
        onoff[j] = 1;
      } else {
        onoff[j] = 0;
      }
    }
    if (judge() == true) {
      ret += 1;
    }
  }
  cout << ret;
  return 0;
}
