n,m=map(int,input().split())
k=[]
for i in range(m):
    k.append(list(map(int,input().split()))[1:])
p=list(map(int,input().split()))
a=0
for i in range(2**n):
    i=list(map(int,list(bin(i)[2:].zfill(n))))
    for j in range(m):
        x=p[j]
        for l in k[j]:
            x^=i[l-1]
        if x==1:break
    else:a+=1
print(a)