from itertools import product

#入力
N,M=map(int,input().split())
ks=[list(map(int,input().split())) for _ in range(M)]
p=[int(x) for x in input().split()]
#print(ks)

ans=0
for i in product([0,1],repeat=N):
    ok=True
    for j in range(M):
        j_on_cnt=0
        for k in ks[j][1:]:
            j_on_cnt+=i[k-1]
            
        if j_on_cnt%2 != p[j]:
            ok=False
            break
    if ok:
        ans+=1
print(ans) 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)] int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x p=[int(x) for x in input().split()] p [int(x) for x in input().split()] ans=0 ans 0 for i in product([0,1],repeat=N):
    ok=True
    for j in range(M):
        j_on_cnt=0
        for k in ks[j][1:]:
            j_on_cnt+=i[k-1]
            
        if j_on_cnt%2 != p[j]:
            ok=False
            break
    if ok:
        ans+=1 i product([0,1],repeat=N) product [0,1] 0 1 repeat=N repeat N ok=True ok True for j in range(M):
        j_on_cnt=0
        for k in ks[j][1:]:
            j_on_cnt+=i[k-1]
            
        if j_on_cnt%2 != p[j]:
            ok=False
            break
     j range(M) range M j_on_cnt=0 j_on_cnt 0 for k in ks[j][1:]:
            j_on_cnt+=i[k-1]
            
         k ks[j][1:] [j] ks j 1: 1 j_on_cnt+=i[k-1] j_on_cnt i[k-1] i k-1 k 1 if j_on_cnt%2 != p[j]:
            ok=False
            break
     j_on_cnt%2 != p[j] j_on_cnt%2 j_on_cnt 2 p[j] p j ok=False ok False break if ok:
        ans+=1 ok ans+=1 ans 1 print(ans) print ans ks=[list(map(int,input().split())) for _ in range(M)] [list(map(int,input().split())) for _ in range(M)] ks ans+=1 1 ans j_on_cnt+=i[k-1] i[k-1] j_on_cnt ans=0 0 ans ok=False False ok N,M=map(int,input().split()) map(int,input().split()) N ok=True True ok j_on_cnt=0 0 j_on_cnt p=[int(x) for x in input().split()] [int(x) for x in input().split()] p M=map(int,input().split()) map(int,input().split()) M
from itertools import product

#入力
N,M=map(int,input().split())
ks=[list(map(int,input().split())) for _ in range(M)]
p=[int(x) for x in input().split()]
#print(ks)

ans=0
for i in product([0,1],repeat=N):
    ok=True
    for j in range(M):
        j_on_cnt=0
        for k in ks[j][1:]:
            j_on_cnt+=i[k-1]
            
        if j_on_cnt%2 != p[j]:
            ok=False
            break
    if ok:
        ans+=1
print(ans)