/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/

	coding: utf-8
	lang: C (GCC 5.4.1)
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int n, m;
	int num[10][10];
	int k;
	int p[10];

	scanf("%d %d", &n, &m);
	
	// input & setup
	for (int i = 0; i < 10; ++i){
		for (int j = 0; j < 10; ++j)	num[i][j] = 0;
	}
	for (int i = 0; i < m; ++i){
		scanf("%d", &k);
		for (int j = 0; j < k; ++j){
			int c;
			scanf("%d", &c);
			num[i][c - 1] = 1;
		}
	}
	for (int i = 0; i < m; ++i) scanf("%d", &p[i]);
	
	// countup
	int ans = 0;
	for (int i = 0; i < (1 << n); ++i) {
		int chkflag = 1;
		for (int j = 0; j < m; ++j) {
			int bitbitcnt = 0;
			for (int l = 0; l < n; ++l) {
				if(num[j][l] & i >> l) bitcnt += 1;
			}
			if(bitcnt % 2 != p[j]) chkflag = 0;
		}
		if(chkflag) ans += 1;
	}
	printf("%d\n", ans);
	return 0;
}
