# coding: utf-8
# Your code here!
N,M=map(int,input().split())
k=[list(map(int,input().split())) for _ in range(M)]
p=list(map(int,input().split()))
#print(k)
#cnt=0
#ok=[[False]*N for _ in range(M)]
#print(ok)
ans=0
for i in range(2**N):
    switch=[False]*N
    #print(switch)
    #on=0
    #ans=0
    for j in range(N):
        if ((i>>j) & 1):
            switch[N-j-1]=True
    #print(switch)

        light=True
        for m in range(M):
            cnt=0
            for o in range(k[m][0]):
                #cnt=0
                if switch[k[m][o+1]-1]==True:
                    cnt+=1

            if not (cnt%2==p[m] and cnt!=0):
                light=False
        if light==True:
            ans+=1
      
            
print(ans)

#cf. https://www.planeta.tokyo/entry/3963/