N,M = map(int,input().split())
X = [list(map(int,input().split())) for i in range(M)]
p = list(map(int,input().split()))

for i in range(M):
	del X[i][0]

count = 0
for i in range(2**N):
	check = True
	for j in range(M):
		on = 0
		for k in X[j]:
			if (i >> (k-1)) & 1 == 1:
				on += 1
		if on%2 != p[j]:
			check = False
	if check:
		count += 1

print(count)