N,M = map(int,input().split())

flgs = [0]*M
for i in range(M):
	k,*vals = map(int,input().split())
	for v in vals:
		flgs[i] |= 1 << (v-1)

p = list(map(int,input().split()))

cnt = 0
for bit in range(2**N):
	cnt_tmp = 1
	for f in flgs:
		if len([j for j in range(N) if ((f&bit) & (1<< j)) != 0]) % 2 != p[i]:
			cnt_tmp = 0
	cnt += cnt_tmp
print(cnt)
