N,M=map(int,input().split())
k=[]
for j in range(0,M):
    k.append([int(x) for x in input().split()])
    k[j]=k[j][1:]
p=[int(x) for x in input().split()]
condition=[0]*M
sum_=0
for u in range(0,2**N):
    switch=list(bin(u)[2:].zfill(N))
    for i in range(0,M):
        for j in k[i]:
            condition[i] += int(switch[j-1])
        condition[i] = condition[i] % 2
    #print(switch,condition)
    sum_ += (condition==p)
print(sum_)