import itertools
N, M = map(int, input().split())
k = [list(map(int, input().split()))[1:] for _ in range(M)]
p = list(map(int, input().split()))
print(sum([all([sum([s[j-1] for j in v])%2==t  for v,t in zip(k, p)]) for s in itertools.product([0,1],repeat=N)]))