N,M = map(int,input().split())
lis = [None]*M
for i in range(M):
    lis[i] = list(map(int,input().split()))
p = list(map(int,input().split()))
answer = 0

for bit in range(1<<N):
    count =[]
    for i in range(N): #make bit
        mask = 1<<i
        if mask&bit:
            count.append(1)
        else:
            count.append(0)
        #process
    for j in range(M):
        temp = 0
        for k in range(lis[j][0]):
            temp+=count[lis[j][k+1]-1]
        if temp%2 != p[j]:
            break
    else:
        answer+=1
        print(count)
print(answer)
