N,M=map(int,input().split())
L=[]

for i in range(M):
    m=list(map(int,input().split()))
    L.append(m[1:])

#print(L)

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

ans=0

for i in range(2**N):
    sw=[0 for i in range(M)]
    I=i+0
    for j in range(N):
        if I&1==True:
            for k in range(M):
                if j+1 in L[k]:
                    sw[k]+=1
        I=I>>1
    #print(sw)
    cnt=0
    for j in range(M):
        if sw[j]%2==S[j]:
            cnt+=1
    if cnt==M:
        ans+=1
print(ans) N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M L=[] L [] for i in range(M):
    m=list(map(int,input().split()))
    L.append(m[1:])

#print(L) i range(M) range M m=list(map(int,input().split())) m list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split L.append(m[1:]) L.append L append m[1:] m 1: 1 S=list(map(int,input().split())) S 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):
    sw=[0 for i in range(M)]
    I=i+0
    for j in range(N):
        if I&1==True:
            for k in range(M):
                if j+1 in L[k]:
                    sw[k]+=1
        I=I>>1
    #print(sw)
    cnt=0
    for j in range(M):
        if sw[j]%2==S[j]:
            cnt+=1
    if cnt==M:
        ans+=1 i range(2**N) range 2**N 2 N 0 for i in range(M) for i in range(M) i range(M) range M for i in range(M) 0 sw=[0 for i in range(M)] sw [0 for i in range(M)] I=i+0 I i+0 i 0 for j in range(N):
        if I&1==True:
            for k in range(M):
                if j+1 in L[k]:
                    sw[k]+=1
        I=I>>1
    #print(sw)
     j range(N) range N if I&1==True:
            for k in range(M):
                if j+1 in L[k]:
                    sw[k]+=1
         I&1==True I&1 I 1 True for k in range(M):
                if j+1 in L[k]:
                    sw[k]+=1
         k range(M) range M if j+1 in L[k]:
                    sw[k]+=1
         j+1 in L[k] j+1 j 1 L[k] L k sw[k]+=1 sw[k] sw k 1 I=I>>1 I I>>1 I 1 cnt=0 cnt 0 for j in range(M):
        if sw[j]%2==S[j]:
            cnt+=1
     j range(M) range M if sw[j]%2==S[j]:
            cnt+=1
     sw[j]%2==S[j] sw[j]%2 sw[j] sw j 2 S[j] S j cnt+=1 cnt 1 if cnt==M:
        ans+=1 cnt==M cnt M ans+=1 ans 1 print(ans) print ans L=[] [] L S=list(map(int,input().split())) list(map(int,input().split())) S cnt=0 0 cnt I=I>>1 I>>1 I N,M=map(int,input().split()) map(int,input().split()) N sw=[0 for i in range(M)] [0 for i in range(M)] sw M=map(int,input().split()) map(int,input().split()) M ans=0 0 ans I=i+0 i+0 I m=list(map(int,input().split())) list(map(int,input().split())) m cnt+=1 1 cnt ans+=1 1 ans
N,M=map(int,input().split())
L=[]

for i in range(M):
    m=list(map(int,input().split()))
    L.append(m[1:])

#print(L)

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

ans=0

for i in range(2**N):
    sw=[0 for i in range(M)]
    I=i+0
    for j in range(N):
        if I&1==True:
            for k in range(M):
                if j+1 in L[k]:
                    sw[k]+=1
        I=I>>1
    #print(sw)
    cnt=0
    for j in range(M):
        if sw[j]%2==S[j]:
            cnt+=1
    if cnt==M:
        ans+=1
print(ans)