I=lambda:map(int,input().split())
N,M=I()
sw=[]
for _ in [0]*M:
    _,*s=I()
    sw+=[s]
*p,=I()
r=0
for i in range(2**N):
    k=str(bin(i))[2:].rjust(N,"0")
    f=True
    for j in range(M):
        t=0
        for s in sw[j]:
            if k[s-1]=="1":t+=1
        if t%2!=p[j]:f=False;break
    if f:r+=1
print(r)