n,m = map(int,input().split())
ks = [list(map(int,input().split())) for _ in range(m)]
p = list(map(int,input().split()))

ans = 0
for i in range(2**n):
	flag = True
	for j in range(m):
		res = 0
		for k in ks[j][1:]:
			res += (i//(2**(k-1)))&1
		if res%2 != p[j]:
			flag = False
	if flag == True:
		ans += 1
print(ans)