import itertools

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

lis=[]

for _ in range(m):
  lis.append(list(map(int,input().split())))

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

ans=0
for binary in itertools.product([0,1],repeat=n):
  check=0
  for i in range(m):
    numon=0
    ki=lis[i][0]
    for j in range(ki):
      numon+=binary[lis[i][j+1]-1]
    if (numon+p[i])%2!=0:
      check+=1
  if check==0:
    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 lis=[] lis [] for _ in range(m):
  lis.append(list(map(int,input().split()))) _ range(m) range m lis.append(list(map(int,input().split()))) lis.append lis append list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split 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 binary in itertools.product([0,1],repeat=n):
  check=0
  for i in range(m):
    numon=0
    ki=lis[i][0]
    for j in range(ki):
      numon+=binary[lis[i][j+1]-1]
    if (numon+p[i])%2!=0:
      check+=1
  if check==0:
    ans+=1 binary itertools.product([0,1],repeat=n) itertools.product itertools product [0,1] 0 1 repeat=n repeat n check=0 check 0 for i in range(m):
    numon=0
    ki=lis[i][0]
    for j in range(ki):
      numon+=binary[lis[i][j+1]-1]
    if (numon+p[i])%2!=0:
      check+=1
   i range(m) range m numon=0 numon 0 ki=lis[i][0] ki lis[i][0] [i] lis i 0 for j in range(ki):
      numon+=binary[lis[i][j+1]-1]
     j range(ki) range ki numon+=binary[lis[i][j+1]-1] numon binary[lis[i][j+1]-1] binary lis[i][j+1]-1 lis[i][j+1] [i] lis i j+1 j 1 1 if (numon+p[i])%2!=0:
      check+=1
   (numon+p[i])%2!=0 (numon+p[i])%2 numon+p[i] numon p[i] p i 2 0 check+=1 check 1 if check==0:
    ans+=1 check==0 check 0 ans+=1 ans 1 print(ans) print ans p=list(map(int,input().split())) list(map(int,input().split())) p numon=0 0 numon check=0 0 check numon+=binary[lis[i][j+1]-1] binary[lis[i][j+1]-1] numon ans+=1 1 ans ki=lis[i][0] lis[i][0] ki n,m=map(int,input().split()) map(int,input().split()) n lis=[] [] lis check+=1 1 check ans=0 0 ans m=map(int,input().split()) map(int,input().split()) m
import itertools

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

lis=[]

for _ in range(m):
  lis.append(list(map(int,input().split())))

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

ans=0
for binary in itertools.product([0,1],repeat=n):
  check=0
  for i in range(m):
    numon=0
    ki=lis[i][0]
    for j in range(ki):
      numon+=binary[lis[i][j+1]-1]
    if (numon+p[i])%2!=0:
      check+=1
  if check==0:
    ans+=1

print(ans)