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

ans=0

for i in range(2**n):
    All_On=True
    for j in range(m):
        k_on=0
        for k in range(1,lamp[j][0]+1):
            if i>>lamp[j][k]-1 & 1:
                k_on+=1
        if k_on%2!=p[j]:
            All_On=False
            break
    if All_On:
        ans+=1
print(ans) n,m=map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m lamp=[] lamp [] for i in range(m):
    lamp.append(list(map(int, input().split()))) i range(m) range m lamp.append(list(map(int, input().split()))) lamp.append lamp append list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split 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):
    All_On=True
    for j in range(m):
        k_on=0
        for k in range(1,lamp[j][0]+1):
            if i>>lamp[j][k]-1 & 1:
                k_on+=1
        if k_on%2!=p[j]:
            All_On=False
            break
    if All_On:
        ans+=1 i range(2**n) range 2**n 2 n All_On=True All_On True for j in range(m):
        k_on=0
        for k in range(1,lamp[j][0]+1):
            if i>>lamp[j][k]-1 & 1:
                k_on+=1
        if k_on%2!=p[j]:
            All_On=False
            break
     j range(m) range m k_on=0 k_on 0 for k in range(1,lamp[j][0]+1):
            if i>>lamp[j][k]-1 & 1:
                k_on+=1
         k range(1,lamp[j][0]+1) range 1 lamp[j][0]+1 lamp[j][0] [j] lamp j 0 1 if i>>lamp[j][k]-1 & 1:
                k_on+=1
         i>>lamp[j][k]-1 & 1 i>>lamp[j][k]-1 i lamp[j][k]-1 lamp[j][k] [j] lamp j k 1 1 k_on+=1 k_on 1 if k_on%2!=p[j]:
            All_On=False
            break
     k_on%2!=p[j] k_on%2 k_on 2 p[j] p j All_On=False All_On False break if All_On:
        ans+=1 All_On ans+=1 ans 1 print(ans) print ans n,m=map(int, input().split()) map(int, input().split()) n lamp=[] [] lamp All_On=True True All_On k_on=0 0 k_on All_On=False False All_On ans+=1 1 ans k_on+=1 1 k_on ans=0 0 ans 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())
lamp=[]
for i in range(m):
    lamp.append(list(map(int, input().split())))
p=list(map(int, input().split()))

ans=0

for i in range(2**n):
    All_On=True
    for j in range(m):
        k_on=0
        for k in range(1,lamp[j][0]+1):
            if i>>lamp[j][k]-1 & 1:
                k_on+=1
        if k_on%2!=p[j]:
            All_On=False
            break
    if All_On:
        ans+=1
print(ans)