def main():
	N, M = map(int, input().split())
	S = [[] for _ in range(N)]

	for i in range(M):
		s = list(map(int, input().split()))
		for sw in s[1:]:
			S[sw-1].append(i)
	P = list(map(int, input().split()))
	num = 2**N
	ans = 0
	for n in range(num):
		cur = [0]*M
		for j in range(N):
			if (n >> j)&1 == 1:
				for e in S[j]:
					cur[e-1] += 1
		is_add = True
		for i, c in enumerate(cur):
			if c%2 != P[i]:
				is_add = False
				break
		if is_add:
			ans += 1
	print(ans)


if __name__ == '__main__':
	main()