
n,m=map(int,input().split())
ks=[[] for i in range(m)]
for i in range(m):
    ks[i]=list(map(int,input().split()))
p=list(map(int,input().split()))
ans=0
for i in range(2**n):
    a=[0 for _ in range(n)]
    for j in range(n):
        if (i>>j)&1:
            a[j]=1
    f=0
    for j in range(m):
        x=0
        for q in range(ks[j][0]):
            
            if a[ks[j][q+1]-1]==1:
                x+=1
        if x%2==p[j]:
            f+=1
    if f==m:
        ans+=1
print(ans)
        
        
        
            
    

    
    

         n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m [] for i in range(m) for i in range(m) i range(m) range m for i in range(m) [] ks=[[] for i in range(m)] ks [[] for i in range(m)] for i in range(m):
    ks[i]=list(map(int,input().split())) i range(m) range m ks[i]=list(map(int,input().split())) ks[i] ks i list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split p=list(map(int,input().split())) p list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split ans=0 ans 0 for i in range(2**n):
    a=[0 for _ in range(n)]
    for j in range(n):
        if (i>>j)&1:
            a[j]=1
    f=0
    for j in range(m):
        x=0
        for q in range(ks[j][0]):
            
            if a[ks[j][q+1]-1]==1:
                x+=1
        if x%2==p[j]:
            f+=1
    if f==m:
        ans+=1 i range(2**n) range 2**n 2 n 0 for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) 0 a=[0 for _ in range(n)] a [0 for _ in range(n)] for j in range(n):
        if (i>>j)&1:
            a[j]=1
     j range(n) range n if (i>>j)&1:
            a[j]=1
     (i>>j)&1 i>>j i j 1 a[j]=1 a[j] a j 1 f=0 f 0 for j in range(m):
        x=0
        for q in range(ks[j][0]):
            
            if a[ks[j][q+1]-1]==1:
                x+=1
        if x%2==p[j]:
            f+=1
     j range(m) range m x=0 x 0 for q in range(ks[j][0]):
            
            if a[ks[j][q+1]-1]==1:
                x+=1
         q range(ks[j][0]) range ks[j][0] [j] ks j 0 if a[ks[j][q+1]-1]==1:
                x+=1
         a[ks[j][q+1]-1]==1 a[ks[j][q+1]-1] a ks[j][q+1]-1 ks[j][q+1] [j] ks j q+1 q 1 1 1 x+=1 x 1 if x%2==p[j]:
            f+=1
     x%2==p[j] x%2 x 2 p[j] p j f+=1 f 1 if f==m:
        ans+=1 f==m f m ans+=1 ans 1 print(ans) print ans f=0 0 f p=list(map(int,input().split())) list(map(int,input().split())) p m=map(int,input().split()) map(int,input().split()) m ks=[[] for i in range(m)] [[] for i in range(m)] ks f+=1 1 f x=0 0 x x+=1 1 x n,m=map(int,input().split()) map(int,input().split()) n ans+=1 1 ans ans=0 0 ans a=[0 for _ in range(n)] [0 for _ in range(n)] a

n,m=map(int,input().split())
ks=[[] for i in range(m)]
for i in range(m):
    ks[i]=list(map(int,input().split()))
p=list(map(int,input().split()))
ans=0
for i in range(2**n):
    a=[0 for _ in range(n)]
    for j in range(n):
        if (i>>j)&1:
            a[j]=1
    f=0
    for j in range(m):
        x=0
        for q in range(ks[j][0]):
            
            if a[ks[j][q+1]-1]==1:
                x+=1
        if x%2==p[j]:
            f+=1
    if f==m:
        ans+=1
print(ans)
        
        
        
            
    

    
    

        
