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 func(switch, n):
	if n != N:
		n_switch = [i for i in switch]
		for i in range(M):
			if s_info[n][i]:
				n_switch[i] += 1
		return func(switch, n+1) + func(n_switch, n+1)
	else:
		for i in range(M):
			if switch[i]%2 == cond[i]:
				continue
			else:
				return 0
		return 1

switch = [0 for i in range(M)]
print(func(switch, 0))
