n,m=map(int,input().split())
L=[list(map(int,input().split()))[1:] for _ in range(m)]
P=list(map(int,input().split()))
cnt=0
for i in range(2**n):
    on=bin(i)[2:].zfill(n)
    for l,p in zip(L,P):
        if sum(int(on[s-1]) for s in l)%2!=p:
            break
    else:cnt+=1
print(cnt)