n,m=[int(x) for x in input().split()]
s=[]
for i in range(m):
  k=[int(x) for x in input().split()]
  s.append(k)
p=[int(x) for x in input().split()]

import itertools
l=[]
a=itertools.product(range(2),repeat=n)
for i in a:
  l.append(i)

ans=0
for i in range(2**n):
  ok=[]
  for j in range(m):
    on=0
    for t in range(1,s[j][0]+1):
      e=s[j][t]
      if l[i][e-1]==1:
        on+=1
    if on%2!=p[j]:
      ok.append(False)
  if False not in ok:
    ans+=1

print(ans) 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 n,m=[int(x) for x in input().split()] n [int(x) for x in input().split()] m s=[] s [] for i in range(m):
  k=[int(x) for x in input().split()]
  s.append(k) i range(m) 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 k=[int(x) for x in input().split()] k [int(x) for x in input().split()] s.append(k) s.append s append k 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()] import itertools itertools l=[] l [] a=itertools.product(range(2),repeat=n) a itertools.product(range(2),repeat=n) itertools.product itertools product range(2) range 2 repeat=n repeat n for i in a:
  l.append(i) i a l.append(i) l.append l append i ans=0 ans 0 for i in range(2**n):
  ok=[]
  for j in range(m):
    on=0
    for t in range(1,s[j][0]+1):
      e=s[j][t]
      if l[i][e-1]==1:
        on+=1
    if on%2!=p[j]:
      ok.append(False)
  if False not in ok:
    ans+=1 i range(2**n) range 2**n 2 n ok=[] ok [] for j in range(m):
    on=0
    for t in range(1,s[j][0]+1):
      e=s[j][t]
      if l[i][e-1]==1:
        on+=1
    if on%2!=p[j]:
      ok.append(False)
   j range(m) range m on=0 on 0 for t in range(1,s[j][0]+1):
      e=s[j][t]
      if l[i][e-1]==1:
        on+=1
     t range(1,s[j][0]+1) range 1 s[j][0]+1 s[j][0] [j] s j 0 1 e=s[j][t] e s[j][t] [j] s j t if l[i][e-1]==1:
        on+=1
     l[i][e-1]==1 l[i][e-1] [i] l i e-1 e 1 1 on+=1 on 1 if on%2!=p[j]:
      ok.append(False)
   on%2!=p[j] on%2 on 2 p[j] p j ok.append(False) ok.append ok append False if False not in ok:
    ans+=1 False not in ok False ok ans+=1 ans 1 print(ans) print ans m=[int(x) for x in input().split()] [int(x) for x in input().split()] m s=[] [] s e=s[j][t] s[j][t] e a=itertools.product(range(2),repeat=n) itertools.product(range(2),repeat=n) a l=[] [] l ok=[] [] ok on=0 0 on p=[int(x) for x in input().split()] [int(x) for x in input().split()] p ans=0 0 ans on+=1 1 on ans+=1 1 ans n,m=[int(x) for x in input().split()] [int(x) for x in input().split()] n k=[int(x) for x in input().split()] [int(x) for x in input().split()] k
n,m=[int(x) for x in input().split()]
s=[]
for i in range(m):
  k=[int(x) for x in input().split()]
  s.append(k)
p=[int(x) for x in input().split()]

import itertools
l=[]
a=itertools.product(range(2),repeat=n)
for i in a:
  l.append(i)

ans=0
for i in range(2**n):
  ok=[]
  for j in range(m):
    on=0
    for t in range(1,s[j][0]+1):
      e=s[j][t]
      if l[i][e-1]==1:
        on+=1
    if on%2!=p[j]:
      ok.append(False)
  if False not in ok:
    ans+=1

print(ans)