n,m=map(int,input().split())
K=[]
S=[]
for i in range(m):
  tmp=list(map(int,input().split()))
  K.append(tmp[0])
  S.append(tmp[1:])
P=list(map(int,input().split()))
ans=0
for i in range(2**n):
  bit=format(i,'0'+str(n)+'b')
  bit=list(map(int,bit))
  on_den=0
  for den in range(m):
    on_swi=0
    for s in S[den]:
      on_swi+=bit[s-1]
    if on_swi%2==P[den]:
      on_den+=1
  if on_den==m:
    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 [] for i in range(m):
  tmp=list(map(int,input().split()))
  K.append(tmp[0])
  S.append(tmp[1:]) i range(m) range m tmp=list(map(int,input().split())) tmp list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split K.append(tmp[0]) K.append K append tmp[0] tmp 0 S.append(tmp[1:]) S.append S append tmp[1:] tmp 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 ans=0 ans 0 for i in range(2**n):
  bit=format(i,'0'+str(n)+'b')
  bit=list(map(int,bit))
  on_den=0
  for den in range(m):
    on_swi=0
    for s in S[den]:
      on_swi+=bit[s-1]
    if on_swi%2==P[den]:
      on_den+=1
  if on_den==m:
    ans+=1 i range(2**n) range 2**n 2 n bit=format(i,'0'+str(n)+'b') bit format(i,'0'+str(n)+'b') format i '0'+str(n)+'b' '0'+str(n) '0' str(n) str n 'b' bit=list(map(int,bit)) bit list(map(int,bit)) list map(int,bit) map int bit on_den=0 on_den 0 for den in range(m):
    on_swi=0
    for s in S[den]:
      on_swi+=bit[s-1]
    if on_swi%2==P[den]:
      on_den+=1
   den range(m) range m on_swi=0 on_swi 0 for s in S[den]:
      on_swi+=bit[s-1]
     s S[den] S den on_swi+=bit[s-1] on_swi bit[s-1] bit s-1 s 1 if on_swi%2==P[den]:
      on_den+=1
   on_swi%2==P[den] on_swi%2 on_swi 2 P[den] P den on_den+=1 on_den 1 if on_den==m:
    ans+=1 on_den==m on_den m ans+=1 ans 1 print(ans) print ans K=[] [] K ans+=1 1 ans ans=0 0 ans n,m=map(int,input().split()) map(int,input().split()) n m=map(int,input().split()) map(int,input().split()) m on_swi+=bit[s-1] bit[s-1] on_swi S=[] [] S P=list(map(int,input().split())) list(map(int,input().split())) P bit=format(i,'0'+str(n)+'b') format(i,'0'+str(n)+'b') bit bit=list(map(int,bit)) list(map(int,bit)) bit tmp=list(map(int,input().split())) list(map(int,input().split())) tmp on_den+=1 1 on_den on_den=0 0 on_den on_swi=0 0 on_swi
n,m=map(int,input().split())
K=[]
S=[]
for i in range(m):
  tmp=list(map(int,input().split()))
  K.append(tmp[0])
  S.append(tmp[1:])
P=list(map(int,input().split()))
ans=0
for i in range(2**n):
  bit=format(i,'0'+str(n)+'b')
  bit=list(map(int,bit))
  on_den=0
  for den in range(m):
    on_swi=0
    for s in S[den]:
      on_swi+=bit[s-1]
    if on_swi%2==P[den]:
      on_den+=1
  if on_den==m:
    ans+=1
print(ans)