#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N, M;
  cin >> N >> M;
  int k[11];
  int s[11][11];
  for (int i = 0; i < M; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> s[i][j];
    }
  }
  int p[11];
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int i = 0; i < (1 << N); i++) {
    bool ok = true;
    for (int j = 0; j < M; ++j) {
      int count = 0;
      for (int l = 0; l < k[j]; l++) {
        if ((i >> l) & 1) {
          count++;
        }
      }
      count %= 2;
      if (count != p[j]) {
        ok = false;
      }
    }
    if (ok) {
      ans++;
    }
  }
  cout << ans;
}
