N,M=map(int, input().split())
KS=[[0 for i in range(N+1)] for j in range(M)]
for m in range(M):
    KS[m][:]= list(map(int, input().split()))
P = list(map(int, input().split()))
count=0
answer=0
flag=True
A=[0]*N
for x in range(2**N):
    a=x
    for i in range(N):
        A[i]=a % 2
        a=int(a/2)
    for m in range(M):
        for y in KS[m][1:]:
            count+=A[y-1]
        if count%2!=P[m]:
            flag=False
    if flag==True:
        answer+=1
    flag=True
print(answer)