n,m=map(int,input().split())
S=[]
for _ in range(m):
  s=list(map(int,input().split()))
  S.append(s[1:])
p=list(map(int,input().split()))

ans=0
for i in range(1<<n):
  for k in range(m):
    sw=0
    for j in range(n):
      if (i>>j)&1 and j+1 in S[k]:
        sw+=1
    if sw % 2 != p[k]:
      break
  else:
    ans+=1
print(ans)
 n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m S=[] S [] for _ in range(m):
  s=list(map(int,input().split()))
  S.append(s[1:]) _ range(m) range m s=list(map(int,input().split())) s list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split S.append(s[1:]) S.append S append s[1:] s 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(1<<n):
  for k in range(m):
    sw=0
    for j in range(n):
      if (i>>j)&1 and j+1 in S[k]:
        sw+=1
    if sw % 2 != p[k]:
      break
  else:
    ans+=1 i range(1<<n) range 1<<n 1 n for k in range(m):
    sw=0
    for j in range(n):
      if (i>>j)&1 and j+1 in S[k]:
        sw+=1
    if sw % 2 != p[k]:
      break
  else:
    ans+=1 k range(m) range m sw=0 sw 0 for j in range(n):
      if (i>>j)&1 and j+1 in S[k]:
        sw+=1
     j range(n) range n if (i>>j)&1 and j+1 in S[k]:
        sw+=1
     (i>>j)&1 and j+1 in S[k] (i>>j)&1 i>>j i j 1 j+1 in S[k] j+1 j 1 S[k] S k sw+=1 sw 1 if sw % 2 != p[k]:
      break
   sw % 2 != p[k] sw % 2 sw 2 p[k] p k break ans+=1 ans 1 print(ans) print ans sw=0 0 sw ans=0 0 ans ans+=1 1 ans n,m=map(int,input().split()) map(int,input().split()) n S=[] [] S sw+=1 1 sw s=list(map(int,input().split())) list(map(int,input().split())) s p=list(map(int,input().split())) list(map(int,input().split())) p m=map(int,input().split()) map(int,input().split()) m
n,m=map(int,input().split())
S=[]
for _ in range(m):
  s=list(map(int,input().split()))
  S.append(s[1:])
p=list(map(int,input().split()))

ans=0
for i in range(1<<n):
  for k in range(m):
    sw=0
    for j in range(n):
      if (i>>j)&1 and j+1 in S[k]:
        sw+=1
    if sw % 2 != p[k]:
      break
  else:
    ans+=1
print(ans)

