n,m=map(int,input().split())
p=2

from itertools import product
iterator=product(range(p),repeat=n)

s=[0 for i in range(m)]    
for i in range(m):
    S=list(map(int,input().split()))
    k=S[0]
    s[i]=S[1:]

p=list(map(int,input().split()))

ans=0
for idxs in iterator:
    tmp1=0
    for i in range(m):
        tmp2=0
        for j in s[i]:
            tmp2+=idxs[j-1]
        if tmp2%2==p[i]:
            tmp1+=1
    if tmp1==m:
        ans+=1
print(ans) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m p=2 p 2 from itertools import product iterator=product(range(p),repeat=n) iterator product(range(p),repeat=n) product range(p) range p repeat=n repeat n 0 for i in range(m) for i in range(m) i range(m) range m for i in range(m) 0 s=[0 for i in range(m)] s [0 for i in range(m)] for i in range(m):
    S=list(map(int,input().split()))
    k=S[0]
    s[i]=S[1:] 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 k=S[0] k S[0] S 0 s[i]=S[1:] s[i] s i S[1:] S 1: 1 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 idxs in iterator:
    tmp1=0
    for i in range(m):
        tmp2=0
        for j in s[i]:
            tmp2+=idxs[j-1]
        if tmp2%2==p[i]:
            tmp1+=1
    if tmp1==m:
        ans+=1 idxs iterator tmp1=0 tmp1 0 for i in range(m):
        tmp2=0
        for j in s[i]:
            tmp2+=idxs[j-1]
        if tmp2%2==p[i]:
            tmp1+=1
     i range(m) range m tmp2=0 tmp2 0 for j in s[i]:
            tmp2+=idxs[j-1]
         j s[i] s i tmp2+=idxs[j-1] tmp2 idxs[j-1] idxs j-1 j 1 if tmp2%2==p[i]:
            tmp1+=1
     tmp2%2==p[i] tmp2%2 tmp2 2 p[i] p i tmp1+=1 tmp1 1 if tmp1==m:
        ans+=1 tmp1==m tmp1 m ans+=1 ans 1 print(ans) print ans m=map(int,input().split()) map(int,input().split()) m tmp1+=1 1 tmp1 ans+=1 1 ans n,m=map(int,input().split()) map(int,input().split()) n iterator=product(range(p),repeat=n) product(range(p),repeat=n) iterator s=[0 for i in range(m)] [0 for i in range(m)] s S=list(map(int,input().split())) list(map(int,input().split())) S p=list(map(int,input().split())) list(map(int,input().split())) p p=2 2 p tmp2=0 0 tmp2 tmp2+=idxs[j-1] idxs[j-1] tmp2 ans=0 0 ans tmp1=0 0 tmp1 k=S[0] S[0] k
n,m=map(int,input().split())
p=2

from itertools import product
iterator=product(range(p),repeat=n)

s=[0 for i in range(m)]    
for i in range(m):
    S=list(map(int,input().split()))
    k=S[0]
    s[i]=S[1:]

p=list(map(int,input().split()))

ans=0
for idxs in iterator:
    tmp1=0
    for i in range(m):
        tmp2=0
        for j in s[i]:
            tmp2+=idxs[j-1]
        if tmp2%2==p[i]:
            tmp1+=1
    if tmp1==m:
        ans+=1
print(ans)