#include <bits/stdc++.h>
const long long maxn = 1005;
const long long INF = 1e17 + 6;
using namespace std;
long long n, m, a[maxn], b[maxn], c[maxn];
long long t[maxn][maxn];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  for (long long i = 1; i <= m; i++) {
    long long x;
    cin >> b[i];
    for (long long j = 1; j <= b[i]; j++) {
      cin >> t[i][j];
    }
  }
  for (long long i = 1; i <= m; i++) cin >> a[i];
  long long ans = 0;
  for (long long i = 0; i <= (1 << n) - 1; i++) {
    long long key = 1;
    long long ji = 0;
    for (long long u = 1; u <= m; u++) {
      for (long long j = 1; j <= b[u]; j++) {
        if ((1 << (t[u][j] - 1)) & i) ji++;
      }
      if (ji % 2 != a[u]) key = 0;
    }
    if (key) ans++;
  }
  cout << ans;
  return 0;
}
