n,m=map(int,input().split())
s=[]
for i in range(m):
  inp=list(map(lambda x:int(x)-1,input().split()))
  s.append(inp[1:])
p=list(map(int,input().split()))
c=0
for i in range(2**n):
  st=[]
  for j in range(m):
    t=0
    for k in s[j]:
      if i&(2**k):
        t^=1
    st.append(t)
  if p==st:
    c+=1
print(c) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m s=[] s [] for i in range(m):
  inp=list(map(lambda x:int(x)-1,input().split()))
  s.append(inp[1:]) i range(m) range m inp=list(map(lambda x:int(x)-1,input().split())) inp list(map(lambda x:int(x)-1,input().split())) list map(lambda x:int(x)-1,input().split()) map lambda x:int(x)-1 int(x)-1 int(x) int x 1 x input().split() ().split () input split s.append(inp[1:]) s.append s append inp[1:] inp 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 c=0 c 0 for i in range(2**n):
  st=[]
  for j in range(m):
    t=0
    for k in s[j]:
      if i&(2**k):
        t^=1
    st.append(t)
  if p==st:
    c+=1 i range(2**n) range 2**n 2 n st=[] st [] for j in range(m):
    t=0
    for k in s[j]:
      if i&(2**k):
        t^=1
    st.append(t)
   j range(m) range m t=0 t 0 for k in s[j]:
      if i&(2**k):
        t^=1
     k s[j] s j if i&(2**k):
        t^=1
     i&(2**k) i 2**k 2 k t^=1 t 1 st.append(t) st.append st append t if p==st:
    c+=1 p==st p st c+=1 c 1 print(c) print c inp=list(map(lambda x:int(x)-1,input().split())) list(map(lambda x:int(x)-1,input().split())) inp c=0 0 c t=0 0 t s=[] [] s p=list(map(int,input().split())) list(map(int,input().split())) p m=map(int,input().split()) map(int,input().split()) m t^=1 1 t c+=1 1 c n,m=map(int,input().split()) map(int,input().split()) n st=[] [] st
n,m=map(int,input().split())
s=[]
for i in range(m):
  inp=list(map(lambda x:int(x)-1,input().split()))
  s.append(inp[1:])
p=list(map(int,input().split()))
c=0
for i in range(2**n):
  st=[]
  for j in range(m):
    t=0
    for k in s[j]:
      if i&(2**k):
        t^=1
    st.append(t)
  if p==st:
    c+=1
print(c)