import itertools
n,m=map(int, input().split())
k=[list(map(int, input().split())) for i in range(m)]
p=list(map(int, input().split()))
bit=list(itertools.product([0,1], repeat=n))
ans=0
for i in bit:
  cnt=0
  for j in range(m):
    cnt2=0
    for l in range(1,k[j][0]+1):
      if i[k[j][l]-1]==1:
        cnt2+=1
    if cnt2%2==p[j]:
      cnt+=1
  if cnt==m:
    ans+=1
print(ans) import itertools itertools n,m=map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m list(map(int, input().split())) for i in range(m) for i in range(m) i range(m) range m for i in range(m) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split k=[list(map(int, input().split())) for i in range(m)] k [list(map(int, input().split())) for i in range(m)] p=list(map(int, input().split())) p list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split bit=list(itertools.product([0,1], repeat=n)) bit list(itertools.product([0,1], repeat=n)) list itertools.product([0,1], repeat=n) itertools.product itertools product [0,1] 0 1 repeat=n repeat n ans=0 ans 0 for i in bit:
  cnt=0
  for j in range(m):
    cnt2=0
    for l in range(1,k[j][0]+1):
      if i[k[j][l]-1]==1:
        cnt2+=1
    if cnt2%2==p[j]:
      cnt+=1
  if cnt==m:
    ans+=1 i bit cnt=0 cnt 0 for j in range(m):
    cnt2=0
    for l in range(1,k[j][0]+1):
      if i[k[j][l]-1]==1:
        cnt2+=1
    if cnt2%2==p[j]:
      cnt+=1
   j range(m) range m cnt2=0 cnt2 0 for l in range(1,k[j][0]+1):
      if i[k[j][l]-1]==1:
        cnt2+=1
     l range(1,k[j][0]+1) range 1 k[j][0]+1 k[j][0] [j] k j 0 1 if i[k[j][l]-1]==1:
        cnt2+=1
     i[k[j][l]-1]==1 i[k[j][l]-1] i k[j][l]-1 k[j][l] [j] k j l 1 1 cnt2+=1 cnt2 1 if cnt2%2==p[j]:
      cnt+=1
   cnt2%2==p[j] cnt2%2 cnt2 2 p[j] p j cnt+=1 cnt 1 if cnt==m:
    ans+=1 cnt==m cnt m ans+=1 ans 1 print(ans) print ans n,m=map(int, input().split()) map(int, input().split()) n cnt+=1 1 cnt k=[list(map(int, input().split())) for i in range(m)] [list(map(int, input().split())) for i in range(m)] k p=list(map(int, input().split())) list(map(int, input().split())) p ans+=1 1 ans m=map(int, input().split()) map(int, input().split()) m ans=0 0 ans cnt2+=1 1 cnt2 cnt=0 0 cnt cnt2=0 0 cnt2 bit=list(itertools.product([0,1], repeat=n)) list(itertools.product([0,1], repeat=n)) bit
import itertools
n,m=map(int, input().split())
k=[list(map(int, input().split())) for i in range(m)]
p=list(map(int, input().split()))
bit=list(itertools.product([0,1], repeat=n))
ans=0
for i in bit:
  cnt=0
  for j in range(m):
    cnt2=0
    for l in range(1,k[j][0]+1):
      if i[k[j][l]-1]==1:
        cnt2+=1
    if cnt2%2==p[j]:
      cnt+=1
  if cnt==m:
    ans+=1
print(ans)