#include <bits/stdc++.h>
const long long mod = 1000000007LL, inf = 1e9, linf = 1e18;
using namespace std;
using namespace std;
int n, m;
int p[12];
int f[12][12];
int k[12];
int l[12];
int ans;
void check() {
  for (int i = 1; i <= m; i++) {
    int len = k[i];
    int d = 0;
    for (int j = 1; j <= k[i]; j++) {
      if (l[f[i][j]]) d++;
    }
    if (d % 2 != p[i] || d == 0) return;
  }
  ans++;
}
int main() {
  ans = 0;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> k[i];
    for (int j = 1; j <= k[i]; j++) cin >> f[i][j];
  }
  for (int i = 1; i <= m; i++) cin >> p[i];
  long long res = (1 << n) - 1;
  for (long long i = 0; i <= res; i++) {
    for (int j = 0; j < n; j++) {
      l[j] = 0;
      if (i & (1 << j)) {
        l[j] = 1;
      }
    }
    check();
  }
  cout << ans;
}
