N,M=map(int,input().split())
li=[]
ans=0
for i in range(M):
    s=list(map(int,input().split()))
    li.append(s)
p=list(map(int,input().split()))

for j in range(2**N):
    j=bin(j)
    j=str(j)
    j=j[2:]
    while len(j)!=N:
        j="0"+j
    flash=0
    for k in range(M):
        temp=0
        for l in range(li[k][0]):
            if j[li[k][l+1]-1]=="1":
                temp+=1
        if temp%2==p[k]:
            flash+=1
    if flash==M:
        ans+=1
print(ans)
        
             N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M li=[] li [] ans=0 ans 0 for i in range(M):
    s=list(map(int,input().split()))
    li.append(s) i range(M) range M s=list(map(int,input().split())) s list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split li.append(s) li.append li append s p=list(map(int,input().split())) p list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split for j in range(2**N):
    j=bin(j)
    j=str(j)
    j=j[2:]
    while len(j)!=N:
        j="0"+j
    flash=0
    for k in range(M):
        temp=0
        for l in range(li[k][0]):
            if j[li[k][l+1]-1]=="1":
                temp+=1
        if temp%2==p[k]:
            flash+=1
    if flash==M:
        ans+=1 j range(2**N) range 2**N 2 N j=bin(j) j bin(j) bin j j=str(j) j str(j) str j j=j[2:] j j[2:] j 2: 2 while len(j)!=N:
        j="0"+j
     len(j)!=N len(j) len j N j="0"+j j "0"+j "0" j flash=0 flash 0 for k in range(M):
        temp=0
        for l in range(li[k][0]):
            if j[li[k][l+1]-1]=="1":
                temp+=1
        if temp%2==p[k]:
            flash+=1
     k range(M) range M temp=0 temp 0 for l in range(li[k][0]):
            if j[li[k][l+1]-1]=="1":
                temp+=1
         l range(li[k][0]) range li[k][0] [k] li k 0 if j[li[k][l+1]-1]=="1":
                temp+=1
         j[li[k][l+1]-1]=="1" j[li[k][l+1]-1] j li[k][l+1]-1 li[k][l+1] [k] li k l+1 l 1 1 "1" temp+=1 temp 1 if temp%2==p[k]:
            flash+=1
     temp%2==p[k] temp%2 temp 2 p[k] p k flash+=1 flash 1 if flash==M:
        ans+=1 flash==M flash M ans+=1 ans 1 print(ans) print ans flash=0 0 flash j=bin(j) bin(j) j j=j[2:] j[2:] j p=list(map(int,input().split())) list(map(int,input().split())) p temp=0 0 temp ans=0 0 ans s=list(map(int,input().split())) list(map(int,input().split())) s flash+=1 1 flash temp+=1 1 temp N,M=map(int,input().split()) map(int,input().split()) N ans+=1 1 ans j="0"+j "0"+j j M=map(int,input().split()) map(int,input().split()) M li=[] [] li j=str(j) str(j) j
N,M=map(int,input().split())
li=[]
ans=0
for i in range(M):
    s=list(map(int,input().split()))
    li.append(s)
p=list(map(int,input().split()))

for j in range(2**N):
    j=bin(j)
    j=str(j)
    j=j[2:]
    while len(j)!=N:
        j="0"+j
    flash=0
    for k in range(M):
        temp=0
        for l in range(li[k][0]):
            if j[li[k][l+1]-1]=="1":
                temp+=1
        if temp%2==p[k]:
            flash+=1
    if flash==M:
        ans+=1
print(ans)
        
            
