N,M=map(int,input().split())
k_i=[]
S=[]
for i in range(M):
  l = list(map(int,input().split()))
  k_i.append(l[0])
  S.append(l[1:])
P=list(map(int,input().split()))
ans=0
for i in range(2**N):
  flag=1
  for j in range(M):
    res=0
    for k,x in enumerate(bin(i)[2:][::-1]):
      if x=="1" and k+1 in S[j]:
        res+=1
    if res%2 != P[j] :
      flag=0
      break
    
  if flag:
    ans+=1
print(ans) N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M k_i=[] k_i [] S=[] S [] for i in range(M):
  l = list(map(int,input().split()))
  k_i.append(l[0])
  S.append(l[1:]) i range(M) range M l = list(map(int,input().split())) l list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split k_i.append(l[0]) k_i.append k_i append l[0] l 0 S.append(l[1:]) S.append S append l[1:] l 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):
  flag=1
  for j in range(M):
    res=0
    for k,x in enumerate(bin(i)[2:][::-1]):
      if x=="1" and k+1 in S[j]:
        res+=1
    if res%2 != P[j] :
      flag=0
      break
    
  if flag:
    ans+=1 i range(2**N) range 2**N 2 N flag=1 flag 1 for j in range(M):
    res=0
    for k,x in enumerate(bin(i)[2:][::-1]):
      if x=="1" and k+1 in S[j]:
        res+=1
    if res%2 != P[j] :
      flag=0
      break
    
   j range(M) range M res=0 res 0 for k,x in enumerate(bin(i)[2:][::-1]):
      if x=="1" and k+1 in S[j]:
        res+=1
     k x enumerate(bin(i)[2:][::-1]) enumerate bin(i)[2:][::-1] [2:] (i) bin i 2: 2 ::-1 -1 if x=="1" and k+1 in S[j]:
        res+=1
     x=="1" and k+1 in S[j] x=="1" x "1" k+1 in S[j] k+1 k 1 S[j] S j res+=1 res 1 if res%2 != P[j] :
      flag=0
      break
    
   res%2 != P[j] res%2 res 2 P[j] P j flag=0 flag 0 break if flag:
    ans+=1 flag ans+=1 ans 1 print(ans) print ans flag=0 0 flag ans=0 0 ans M=map(int,input().split()) map(int,input().split()) M res+=1 1 res k_i=[] [] k_i res=0 0 res l = list(map(int,input().split())) list(map(int,input().split())) l flag=1 1 flag ans+=1 1 ans S=[] [] S P=list(map(int,input().split())) list(map(int,input().split())) P N,M=map(int,input().split()) map(int,input().split()) N
N,M=map(int,input().split())
k_i=[]
S=[]
for i in range(M):
  l = list(map(int,input().split()))
  k_i.append(l[0])
  S.append(l[1:])
P=list(map(int,input().split()))
ans=0
for i in range(2**N):
  flag=1
  for j in range(M):
    res=0
    for k,x in enumerate(bin(i)[2:][::-1]):
      if x=="1" and k+1 in S[j]:
        res+=1
    if res%2 != P[j] :
      flag=0
      break
    
  if flag:
    ans+=1
print(ans)