from itertools import product
n,m=map(int,input().split())
ks=[list(map(int,input().split())) for _ in range(m)]
p=list(map(int,input().split()))
count=0
for i in product([0,1],repeat=n):
    for j in range(m):
        
        temp=0
        for k in range(ks[j][0]):
            if i[ks[j][k+1]-1]==1:
                temp+=1
        if temp%2!=p[j]:
            break
    else: 
        count+=1
print(count) from itertools import product n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m list(map(int,input().split())) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split ks=[list(map(int,input().split())) for _ in range(m)] ks [list(map(int,input().split())) for _ in range(m)] p=list(map(int,input().split())) p list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split count=0 count 0 for i in product([0,1],repeat=n):
    for j in range(m):
        
        temp=0
        for k in range(ks[j][0]):
            if i[ks[j][k+1]-1]==1:
                temp+=1
        if temp%2!=p[j]:
            break
    else: 
        count+=1 i product([0,1],repeat=n) product [0,1] 0 1 repeat=n repeat n for j in range(m):
        
        temp=0
        for k in range(ks[j][0]):
            if i[ks[j][k+1]-1]==1:
                temp+=1
        if temp%2!=p[j]:
            break
    else: 
        count+=1 j range(m) range m temp=0 temp 0 for k in range(ks[j][0]):
            if i[ks[j][k+1]-1]==1:
                temp+=1
         k range(ks[j][0]) range ks[j][0] [j] ks j 0 if i[ks[j][k+1]-1]==1:
                temp+=1
         i[ks[j][k+1]-1]==1 i[ks[j][k+1]-1] i ks[j][k+1]-1 ks[j][k+1] [j] ks j k+1 k 1 1 1 temp+=1 temp 1 if temp%2!=p[j]:
            break
     temp%2!=p[j] temp%2 temp 2 p[j] p j break count+=1 count 1 print(count) print count m=map(int,input().split()) map(int,input().split()) m count=0 0 count p=list(map(int,input().split())) list(map(int,input().split())) p temp=0 0 temp count+=1 1 count n,m=map(int,input().split()) map(int,input().split()) n ks=[list(map(int,input().split())) for _ in range(m)] [list(map(int,input().split())) for _ in range(m)] ks temp+=1 1 temp
from itertools import product
n,m=map(int,input().split())
ks=[list(map(int,input().split())) for _ in range(m)]
p=list(map(int,input().split()))
count=0
for i in product([0,1],repeat=n):
    for j in range(m):
        
        temp=0
        for k in range(ks[j][0]):
            if i[ks[j][k+1]-1]==1:
                temp+=1
        if temp%2!=p[j]:
            break
    else: 
        count+=1
print(count)
