N,M=map(int, raw_input().split())
S=[ map(int, raw_input().split())[1:] for _ in range(M) ] 
P=map(int, raw_input().split())

ans=0
for i in range(2**N):
	for m in range(M):
		tmp=0
		for s in S[m]:
			tmp+=( i>>(N-s) ) & 1

		tmp%=2

		if tmp!=P[m]:
			break
	else:
		ans+=1

print ans