N,M = map(int,input().split())
k = [list(map(int,input().split())) for i in range(M)]
p = list(map(int,input().split()))

ans = 0

for bit in range(1<<N):
    for lump in range(M):
        on_lump = 0
        for i in range(N):
            if (bit >> i) & 1 and i in k[lump][1:]:
                on_lump += 1
        if on_lump % 2 != p[lump]:
            break
    else:
        ans += 1
print(ans)