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

ans = 0

for i in range(1<<N):
    for r in range(M):
        on_sum = 0
        for j in range(N):
            if (i >> j) & 1 and j in lamps[r]:
                on_sum += 1
        if on_sum % 2 != p[r]:
            break
    else:
        ans += 1
print(ans)
