import itertools

N, M = map(int, input().split())

k = []
for _ in range(M):
    k.append(list(map(int, input().split()))[1:])

p = list(map(int, input().split()))

ans = 0
for i, s in enumerate(itertools.product([0,1],repeat=N)):
    if all([sum([s[j-1] for j in v])%2==t  for v,t in zip(k, p)]):
        ans += 1
print(ans)

            


