N, M = map(int, input().split())
K = [0]*M
for i in range(M):
    K[i] = list(map(int, input().split()))
P = list(map(int, input().split()))
Ans = 0

for i in range(2**N):
    ii =str(bin(i))[2:].zfill(N)
    Judge = 1
    cnt = 0
    
    for k in range(M):
        for j in range(1,K[k][0]+1):
            cnt += int(ii[K[k][j]-1])                
        if cnt % 2 != P[k]:
            Judge = 0
            break
    if Judge :
        Ans += 1

print(Ans)