#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const long long INF = 1LL << 60;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> bit(M, 0), check(M);
  for (int i = (0); i < (M); i++) {
    int k;
    cin >> k;
    for (int j = (0); j < (k); j++) {
      int s;
      cin >> s;
      bit[i] += pow(2, s - 1);
    }
  }
  for (int j = (0); j < (M); j++) {
    cin >> check[j];
  }
  int ans = 0;
  for (int i = 1; i < (1 << N); i++) {
    bool flag = true;
    for (int j = (0); j < (M); j++) {
      int num = bit[j] & i;
      int bit_j = 0;
      for (int j = 1; j < (1 << N); j = j << 1) {
        if (num & j) bit_j++;
      }
      if (bit_j % 2 != check[j]) {
        flag = false;
        break;
      }
    }
    if (flag) ans++;
  }
  cout << ans << endl;
  return 0;
}
