n,m=map(int,input().split())
k=[]
s=[]
ans=0
for i in range(m):
  kk, *ss=map(int,input().split())
  k.append(kk)
  s.append(ss)
p=list(map(int,input().split()))
for i in range(2**n):
  tmp=[]
  for j in range(n):
    if (i>>j)&1:
      tmp.append(j+1)
  for j in range(m):
    if len(set(tmp)&set(s[j])) % 2 != p[j]:
      break
  else:
    ans+=1
print(ans) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m k=[] k [] s=[] s [] ans=0 ans 0 for i in range(m):
  kk, *ss=map(int,input().split())
  k.append(kk)
  s.append(ss) i range(m) range m kk, *ss=map(int,input().split()) kk map(int,input().split()) map int input().split() ().split () input split *ss ss k.append(kk) k.append k append kk s.append(ss) s.append s append ss p=list(map(int,input().split())) p list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split for i in range(2**n):
  tmp=[]
  for j in range(n):
    if (i>>j)&1:
      tmp.append(j+1)
  for j in range(m):
    if len(set(tmp)&set(s[j])) % 2 != p[j]:
      break
  else:
    ans+=1 i range(2**n) range 2**n 2 n tmp=[] tmp [] for j in range(n):
    if (i>>j)&1:
      tmp.append(j+1)
   j range(n) range n if (i>>j)&1:
      tmp.append(j+1)
   (i>>j)&1 i>>j i j 1 tmp.append(j+1) tmp.append tmp append j+1 j 1 for j in range(m):
    if len(set(tmp)&set(s[j])) % 2 != p[j]:
      break
  else:
    ans+=1 j range(m) range m if len(set(tmp)&set(s[j])) % 2 != p[j]:
      break
   len(set(tmp)&set(s[j])) % 2 != p[j] len(set(tmp)&set(s[j])) % 2 len(set(tmp)&set(s[j])) len set(tmp)&set(s[j]) set(tmp) set tmp set(s[j]) set s[j] s j 2 p[j] p j break ans+=1 ans 1 print(ans) print ans ans=0 0 ans n,m=map(int,input().split()) map(int,input().split()) n kk, *ss=map(int,input().split()) map(int,input().split()) kk ans+=1 1 ans s=[] [] s m=map(int,input().split()) map(int,input().split()) m p=list(map(int,input().split())) list(map(int,input().split())) p tmp=[] [] tmp k=[] [] k
n,m=map(int,input().split())
k=[]
s=[]
ans=0
for i in range(m):
  kk, *ss=map(int,input().split())
  k.append(kk)
  s.append(ss)
p=list(map(int,input().split()))
for i in range(2**n):
  tmp=[]
  for j in range(n):
    if (i>>j)&1:
      tmp.append(j+1)
  for j in range(m):
    if len(set(tmp)&set(s[j])) % 2 != p[j]:
      break
  else:
    ans+=1
print(ans)