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):
		j = 0
		cur = list(P)
		while n >> j > 0:
			if (n >> j)&1 == 1:
				for e in S[j]:
					if cur[e-1] == 0:
						cur[e-1] = 1
					else:
						cur[e-1] = 0
			j += 1
		if all(x == 0 for x in cur):
			ans += 1
	print(ans)


if __name__ == '__main__':
	main()