#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 7;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
map<int, int> mp;
int p[N], k[N], s[N][N];
int get_bit(int x, int i) { return (x >> i) & 1; }
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    scanf("%d", &k[i]);
    for (int j = 1; j <= k[i]; j++) scanf("%d", &s[i][j]);
  }
  for (int i = 1; i <= m; i++) cin >> p[i];
  int sum = 0;
  for (int i = 0; i < pow(2, n); i++) {
    int f = 0;
    for (int r = 1; r <= m; r++) {
      int ans = 0;
      for (int l = 1; l <= k[r]; l++)
        if (i & (1 << (s[r][l] - 1))) ans++;
      if (ans % 2 == p[r]) {
        f++;
      }
    }
    if (f == m) sum++;
  }
  cout << sum << endl;
  return 0;
}
