N,M = map(int,input().split())
s_info = [[False for i in range(M)] for j in range(N)]
for i in range(M):
	l = list(map(int,input().split()))
	for j in range(1, l[0]+1):
		s_info[j-1][i] = True
cond = list(map(int,input().split()))


def dec2bin(n, d):
	ret = []
	for i in range(d):
		ret.append(n%2)
		n = n // 2
	return ret

ans = 0
for i in range(2**N):
	switch = dec2bin(i, N)
	flg = True
	for m in range(M):
		if sum([1 for n in range(N) if switch[n] == 1 and s_info[n][m]]) % 2 != cond[m]:
			flg =False
			break
	if flg:
		ans += 1

print(ans)