N, M = map(int, input().split())
A = [list(map(int, input().split()))[1:] for _ in range(M)]
P = list(map(int, input().split()))

c = 0
for n in range(1 << N):
    for i, S in enumerate(A):
        #print(P[i] , sum(n >> s-1 & 1 for s in S))
        if P[i] ^ sum(n >> s-1 & 1 for s in S) & 1:
            break
    else:
        c += 1

print(c)
