n,m = map(int,raw_input().split())
switch = []
for i in xrange(m):
	a = map(int,raw_input().split())
	conn = [0]*n
	for x in a[1:]:
		conn[x-1] = 1
	switch.append(conn)
p = map(int,raw_input().split())
res = 0
for i in xrange(2**n):
	temp = i
	lit = [0]*m
	for j in xrange(n):
		if temp%2 == 1:
			for b in xrange(m):
				if switch[b][j]:
					lit[b] += 1
		temp /= 2
	res += 1
	for j in xrange(m):
		if lit[j]%2 != p[j]:
			res -= 1
			break
print res