n,m=map(int,input().split())
ks=[]
for i in range(m):
  t=list(map(int,input().split()))
  ks.append(t)
p=list(map(int,input().split()))

ans=0
for i in range(1<<n):
  on=0
  for j in range(m):
    cnt=0
    for k in range(ks[j][0]):
      if 1<<(ks[j][k+1]-1) & i:
        cnt+=1
    if cnt%2==p[j]:
      on+=1
    if on==m:
      ans+=1
print(ans) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m ks=[] ks [] for i in range(m):
  t=list(map(int,input().split()))
  ks.append(t) i range(m) range m t=list(map(int,input().split())) t list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split ks.append(t) ks.append ks append t 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):
  on=0
  for j in range(m):
    cnt=0
    for k in range(ks[j][0]):
      if 1<<(ks[j][k+1]-1) & i:
        cnt+=1
    if cnt%2==p[j]:
      on+=1
    if on==m:
      ans+=1 i range(1<<n) range 1<<n 1 n on=0 on 0 for j in range(m):
    cnt=0
    for k in range(ks[j][0]):
      if 1<<(ks[j][k+1]-1) & i:
        cnt+=1
    if cnt%2==p[j]:
      on+=1
    if on==m:
      ans+=1 j range(m) range m cnt=0 cnt 0 for k in range(ks[j][0]):
      if 1<<(ks[j][k+1]-1) & i:
        cnt+=1
     k range(ks[j][0]) range ks[j][0] [j] ks j 0 if 1<<(ks[j][k+1]-1) & i:
        cnt+=1
     1<<(ks[j][k+1]-1) & i 1<<(ks[j][k+1]-1) 1 ks[j][k+1]-1 ks[j][k+1] [j] ks j k+1 k 1 1 i cnt+=1 cnt 1 if cnt%2==p[j]:
      on+=1
     cnt%2==p[j] cnt%2 cnt 2 p[j] p j on+=1 on 1 if on==m:
      ans+=1 on==m on m ans+=1 ans 1 print(ans) print ans cnt=0 0 cnt ans+=1 1 ans t=list(map(int,input().split())) list(map(int,input().split())) t on+=1 1 on m=map(int,input().split()) map(int,input().split()) m p=list(map(int,input().split())) list(map(int,input().split())) p ans=0 0 ans ks=[] [] ks on=0 0 on n,m=map(int,input().split()) map(int,input().split()) n cnt+=1 1 cnt
n,m=map(int,input().split())
ks=[]
for i in range(m):
  t=list(map(int,input().split()))
  ks.append(t)
p=list(map(int,input().split()))

ans=0
for i in range(1<<n):
  on=0
  for j in range(m):
    cnt=0
    for k in range(ks[j][0]):
      if 1<<(ks[j][k+1]-1) & i:
        cnt+=1
    if cnt%2==p[j]:
      on+=1
    if on==m:
      ans+=1
print(ans)