N,M=map(int,input().split(' '))
lights=[]
slist=[]

for i in range(M):
  line=input()
  
  switches=list(map(int,line.split(' ')))
  s_bit=0
  for switch in switches[1:]:
    s_bit+=1<<(switch-1)
  slist.append(s_bit)

plist=list(map(int,input().split(' ')))

#print('slist {}'.format(slist))
#print('plist {}'.format(plist))
ans=0
for state_switches in range((1<<N)):
  on_num=0
  #print('====')
  #print(state_switches)
  for k in range(M):
    s_bit=slist[k]
    s_on=s_bit&state_switches
    #print('s_bit state_swithces s_on : {} :{} : {}'.format(s_bit,state_switches,s_on))
    s_num=0
    for i in range(N):
      #print('s_on 1<<i result {} {} {}'.format(s_on,1<<i,s_on&(1<<i))) 
      s_num+=(s_on&(1<<i))>>i
    #print('s_num p {} {}'.format(s_num,plist[k]))
    if s_num%2==plist[k]:
      on_num+=1
    #print(on_num)
  if on_num==M:
    ans+=1

print(ans) N,M=map(int,input().split(' ')) N map(int,input().split(' ')) map int input().split(' ') ().split () input split ' ' M lights=[] lights [] slist=[] slist [] for i in range(M):
  line=input()
  
  switches=list(map(int,line.split(' ')))
  s_bit=0
  for switch in switches[1:]:
    s_bit+=1<<(switch-1)
  slist.append(s_bit) i range(M) range M line=input() line input() input switches=list(map(int,line.split(' '))) switches list(map(int,line.split(' '))) list map(int,line.split(' ')) map int line.split(' ') line.split line split ' ' s_bit=0 s_bit 0 for switch in switches[1:]:
    s_bit+=1<<(switch-1)
   switch switches[1:] switches 1: 1 s_bit+=1<<(switch-1) s_bit 1<<(switch-1) 1 switch-1 switch 1 slist.append(s_bit) slist.append slist append s_bit plist=list(map(int,input().split(' '))) plist list(map(int,input().split(' '))) list map(int,input().split(' ')) map int input().split(' ') ().split () input split ' ' ans=0 ans 0 for state_switches in range((1<<N)):
  on_num=0
  #print('====')
  #print(state_switches)
  for k in range(M):
    s_bit=slist[k]
    s_on=s_bit&state_switches
    #print('s_bit state_swithces s_on : {} :{} : {}'.format(s_bit,state_switches,s_on))
    s_num=0
    for i in range(N):
      #print('s_on 1<<i result {} {} {}'.format(s_on,1<<i,s_on&(1<<i))) 
      s_num+=(s_on&(1<<i))>>i
    #print('s_num p {} {}'.format(s_num,plist[k]))
    if s_num%2==plist[k]:
      on_num+=1
    #print(on_num)
  if on_num==M:
    ans+=1 state_switches range((1<<N)) range 1<<N 1 N on_num=0 on_num 0 for k in range(M):
    s_bit=slist[k]
    s_on=s_bit&state_switches
    #print('s_bit state_swithces s_on : {} :{} : {}'.format(s_bit,state_switches,s_on))
    s_num=0
    for i in range(N):
      #print('s_on 1<<i result {} {} {}'.format(s_on,1<<i,s_on&(1<<i))) 
      s_num+=(s_on&(1<<i))>>i
    #print('s_num p {} {}'.format(s_num,plist[k]))
    if s_num%2==plist[k]:
      on_num+=1
    #print(on_num)
   k range(M) range M s_bit=slist[k] s_bit slist[k] slist k s_on=s_bit&state_switches s_on s_bit&state_switches s_bit state_switches s_num=0 s_num 0 for i in range(N):
      #print('s_on 1<<i result {} {} {}'.format(s_on,1<<i,s_on&(1<<i))) 
      s_num+=(s_on&(1<<i))>>i
    #print('s_num p {} {}'.format(s_num,plist[k]))
     i range(N) range N s_num+=(s_on&(1<<i))>>i s_num (s_on&(1<<i))>>i s_on&(1<<i) s_on 1<<i 1 i i if s_num%2==plist[k]:
      on_num+=1
    #print(on_num)
   s_num%2==plist[k] s_num%2 s_num 2 plist[k] plist k on_num+=1 on_num 1 if on_num==M:
    ans+=1 on_num==M on_num M ans+=1 ans 1 print(ans) print ans lights=[] [] lights ans=0 0 ans s_num+=(s_on&(1<<i))>>i (s_on&(1<<i))>>i s_num s_on=s_bit&state_switches s_bit&state_switches s_on slist=[] [] slist s_bit=slist[k] slist[k] s_bit N,M=map(int,input().split(' ')) map(int,input().split(' ')) N switches=list(map(int,line.split(' '))) list(map(int,line.split(' '))) switches plist=list(map(int,input().split(' '))) list(map(int,input().split(' '))) plist on_num+=1 1 on_num s_bit+=1<<(switch-1) 1<<(switch-1) s_bit s_bit=0 0 s_bit ans+=1 1 ans M=map(int,input().split(' ')) map(int,input().split(' ')) M s_num=0 0 s_num on_num=0 0 on_num line=input() input() line
N,M=map(int,input().split(' '))
lights=[]
slist=[]

for i in range(M):
  line=input()
  
  switches=list(map(int,line.split(' ')))
  s_bit=0
  for switch in switches[1:]:
    s_bit+=1<<(switch-1)
  slist.append(s_bit)

plist=list(map(int,input().split(' ')))

#print('slist {}'.format(slist))
#print('plist {}'.format(plist))
ans=0
for state_switches in range((1<<N)):
  on_num=0
  #print('====')
  #print(state_switches)
  for k in range(M):
    s_bit=slist[k]
    s_on=s_bit&state_switches
    #print('s_bit state_swithces s_on : {} :{} : {}'.format(s_bit,state_switches,s_on))
    s_num=0
    for i in range(N):
      #print('s_on 1<<i result {} {} {}'.format(s_on,1<<i,s_on&(1<<i))) 
      s_num+=(s_on&(1<<i))>>i
    #print('s_num p {} {}'.format(s_num,plist[k]))
    if s_num%2==plist[k]:
      on_num+=1
    #print(on_num)
  if on_num==M:
    ans+=1

print(ans)
