#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int k[m], p[m];
  int s[m][11];
  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 memo[n];
  int ans = 0;
  for (int i = 0; i < pow(2, n); i++) {
    int cri = 1;
    for (int j = 0; j < n; j++) {
      memo[j] = (i & (int)(pow(2, j))) / (pow(2, j));
    }
    for (int j = 0; j < m; j++) {
      int count = 0;
      for (int l = 0; l < k[j]; l++) {
        count += memo[s[j][l]];
      }
      if (count % 2 != p[j]) {
        cri = 0;
      }
    }
    if (cri) {
      ans++;
    }
  }
  cout << ans;
}
