#include <bits/stdc++.h>
using namespace std;
long long ans = 0;
int N, M, tmp, num[15];
vector<int> K, S[15];
bool P[15], flag;
void solve() {
  for (int i = 0; i < (1 << N); i++) {
    fill(num, num + N, 0);
    flag = true;
    for (int j = 0; j < N; j++) {
      if (i & (1 << j)) {
        for (int k = 0, k_len = (S[j].size()); k < k_len; ++k) {
          num[S[j][k]]++;
        }
      };
    }
    for (int i = 0, i_len = (M); i < i_len; ++i) {
      if (num[i] % 2 != P[i]) flag = false;
    }
    if (flag) {
      ans++;
    }
  }
  cout << ans << endl;
}
int main() {
  cin >> N >> M;
  K.resize(M);
  for (int i = 0, i_len = (M); i < i_len; ++i) {
    cin >> K[i];
    for (int j = 0, j_len = (K[i]); j < j_len; ++j) {
      cin >> tmp;
      tmp--;
      S[i].push_back(tmp);
    }
  }
  for (int i = 0, i_len = (M); i < i_len; ++i) cin >> P[i];
  solve();
}
