N,M = [int(i) for i in input().split()] #Nがスイッチの数、Mは電球の数
sss = []
for i in range(M):
    buff = [int(i) for i in input().split()]
    onoff = 0
    for b in buff:
        onoff += 1<<(b-1)
    sss.append(onoff)

ppp = [int(i) for i in input().split()]

ct=0
for i in range(1<<N):
    for s,p in zip(sss,ppp):
        if bin(i&s).count("1")%2!=p:
            break
    else:
        ct+=1

print(ct)