n,m=list(map(int,input().split()))
k=[]
s=[]

def cntbin(num):
    bin_num = bin(num)[2:]
    count = 0
    for i in bin_num:
            count += int(i)
    return count

for i in range(m):
    kk,*ss=list(map(int,input().split()))
    k.append(kk)
    s.append(ss)

p=list(map(int,input().split()))

ans=0
for i in range(2**n):
    ok=True
    for mm in range(m):
        if not ok:break
        mask=0
        for ss in s[mm]:
            mask+=1 << ss-1
        on=cntbin(i&mask)
        if p[mm]!=on%2:
            ok=False

    if ok:ans+=1

print(ans) n,m=list(map(int,input().split())) n list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split m k=[] k [] s=[] s [] def cntbin(num):
    bin_num = bin(num)[2:]
    count = 0
    for i in bin_num:
            count += int(i)
    return count cntbin bin_num = bin(num)[2:] bin_num bin(num)[2:] (num) bin num 2: 2 count = 0 count 0 for i in bin_num:
            count += int(i)
     i bin_num count += int(i) count int(i) int i return count count num num for i in range(m):
    kk,*ss=list(map(int,input().split()))
    k.append(kk)
    s.append(ss) i range(m) range m kk,*ss=list(map(int,input().split())) kk list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split *ss ss k.append(kk) k.append k append kk s.append(ss) s.append s append ss 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):
    ok=True
    for mm in range(m):
        if not ok:break
        mask=0
        for ss in s[mm]:
            mask+=1 << ss-1
        on=cntbin(i&mask)
        if p[mm]!=on%2:
            ok=False

    if ok:ans+=1 i range(2**n) range 2**n 2 n ok=True ok True for mm in range(m):
        if not ok:break
        mask=0
        for ss in s[mm]:
            mask+=1 << ss-1
        on=cntbin(i&mask)
        if p[mm]!=on%2:
            ok=False

     mm range(m) range m if not ok:break
         not ok ok mask=0 mask 0 for ss in s[mm]:
            mask+=1 << ss-1
         ss s[mm] s mm mask+=1 << ss-1 mask 1 << ss-1 1 ss-1 ss 1 on=cntbin(i&mask) on cntbin(i&mask) cntbin i&mask i mask if p[mm]!=on%2:
            ok=False

     p[mm]!=on%2 p[mm] p mm on%2 on 2 ok=False ok False if ok:an ok print(ans) print ans kk,*ss=list(map(int,input().split())) list(map(int,input().split())) kk ok=False False ok k=[] [] k p=list(map(int,input().split())) list(map(int,input().split())) p on=cntbin(i&mask) cntbin(i&mask) on ans=0 0 ans mask=0 0 mask s=[] [] s ok=True True ok n,m=list(map(int,input().split())) list(map(int,input().split())) n m=list(map(int,input().split())) list(map(int,input().split())) m def cntbin(num):
    bin_num = bin(num)[2:]
    count = 0
    for i in bin_num:
            count += int(i)
    return count def cntbin(num):
    bin_num = bin(num)[2:]
    count = 0
    for i in bin_num:
            count += int(i)
    return count cntbin mask+=1 << ss-1 1 << ss-1 mask
n,m=list(map(int,input().split()))
k=[]
s=[]

def cntbin(num):
    bin_num = bin(num)[2:]
    count = 0
    for i in bin_num:
            count += int(i)
    return count

for i in range(m):
    kk,*ss=list(map(int,input().split()))
    k.append(kk)
    s.append(ss)

p=list(map(int,input().split()))

ans=0
for i in range(2**n):
    ok=True
    for mm in range(m):
        if not ok:break
        mask=0
        for ss in s[mm]:
            mask+=1 << ss-1
        on=cntbin(i&mask)
        if p[mm]!=on%2:
            ok=False

    if ok:ans+=1

print(ans)