import itertools
N,M=map(int,input().split())
s=[]
for _ in range(M):
    s.append(list(map(int,input().split()))[1:])
p=list(map(int,input().split()))
ans=0
for bit in itertools.product([0,1],repeat=N):
    count=[0]*M
    for light in range(M):
        for k in s[light]:
            count[light]+=bit[k-1]
    if all (count[i]%2==p[i] for i in range(M)):
        ans+=1
print(ans) import itertools itertools N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M s=[] s [] for _ in range(M):
    s.append(list(map(int,input().split()))[1:]) _ range(M) range M s.append(list(map(int,input().split()))[1:]) s.append s append list(map(int,input().split()))[1:] (map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split 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 bit in itertools.product([0,1],repeat=N):
    count=[0]*M
    for light in range(M):
        for k in s[light]:
            count[light]+=bit[k-1]
    if all (count[i]%2==p[i] for i in range(M)):
        ans+=1 bit itertools.product([0,1],repeat=N) itertools.product itertools product [0,1] 0 1 repeat=N repeat N count=[0]*M count [0]*M [0] 0 M for light in range(M):
        for k in s[light]:
            count[light]+=bit[k-1]
     light range(M) range M for k in s[light]:
            count[light]+=bit[k-1]
     k s[light] s light count[light]+=bit[k-1] count[light] count light bit[k-1] bit k-1 k 1 if all (count[i]%2==p[i] for i in range(M)):
        ans+=1 all (count[i]%2==p[i] for i in range(M)) all count[i]%2==p[i] count[i]%2 count[i] count i 2 p[i] p i ans+=1 ans 1 print(ans) print ans M=map(int,input().split()) map(int,input().split()) M p=list(map(int,input().split())) list(map(int,input().split())) p s=[] [] s ans=0 0 ans count=[0]*M [0]*M count N,M=map(int,input().split()) map(int,input().split()) N ans+=1 1 ans
import itertools
N,M=map(int,input().split())
s=[]
for _ in range(M):
    s.append(list(map(int,input().split()))[1:])
p=list(map(int,input().split()))
ans=0
for bit in itertools.product([0,1],repeat=N):
    count=[0]*M
    for light in range(M):
        for k in s[light]:
            count[light]+=bit[k-1]
    if all (count[i]%2==p[i] for i in range(M)):
        ans+=1
print(ans)