n, m = (int(xi) for xi in input().split())
k = []
for xi in range(m):
    ksub = [int(xi) for xi in input().split()]
    k.append(ksub[1:])
p = [int(xi) for xi in input().split()]

# print(k)


countN = 0
for Nnum in range(2**n):
    txt = bin(Nnum)[2:]
    txt = "0"*(n-len(txt))+txt
    # print(txt)

    for li in range(m):
        ltxt = "0"*n
        for xi in range(len(k[li])):
            point = k[li][xi]-1
            ltxt = ltxt[:point]+"1"+ltxt[point+1:]
        # print(ltxt)
        count = 0
        for xi in range(n):
            if txt[xi]=="1" and ltxt[xi]=="1":
                count += 1
        if count%2==p[li]:
            switch = True
        else:
            switch = False
            break
    if switch: countN += 1

print(countN) int(xi) for xi in input().split() for xi in input().split() xi input().split() ().split () input split for xi in input().split() int(xi) int xi n, m = (int(xi) for xi in input().split()) n (int(xi) for xi in input().split()) m k = [] k [] for xi in range(m):
    ksub = [int(xi) for xi in input().split()]
    k.append(ksub[1:]) xi range(m) range m int(xi) for xi in input().split() for xi in input().split() xi input().split() ().split () input split for xi in input().split() int(xi) int xi ksub = [int(xi) for xi in input().split()] ksub [int(xi) for xi in input().split()] k.append(ksub[1:]) k.append k append ksub[1:] ksub 1: 1 int(xi) for xi in input().split() for xi in input().split() xi input().split() ().split () input split for xi in input().split() int(xi) int xi p = [int(xi) for xi in input().split()] p [int(xi) for xi in input().split()] countN = 0 countN 0 for Nnum in range(2**n):
    txt = bin(Nnum)[2:]
    txt = "0"*(n-len(txt))+txt
    # print(txt)

    for li in range(m):
        ltxt = "0"*n
        for xi in range(len(k[li])):
            point = k[li][xi]-1
            ltxt = ltxt[:point]+"1"+ltxt[point+1:]
        # print(ltxt)
        count = 0
        for xi in range(n):
            if txt[xi]=="1" and ltxt[xi]=="1":
                count += 1
        if count%2==p[li]:
            switch = True
        else:
            switch = False
            break
    if switch: countN += 1 Nnum range(2**n) range 2**n 2 n txt = bin(Nnum)[2:] txt bin(Nnum)[2:] (Nnum) bin Nnum 2: 2 txt = "0"*(n-len(txt))+txt txt "0"*(n-len(txt))+txt "0"*(n-len(txt)) "0" n-len(txt) n len(txt) len txt txt for li in range(m):
        ltxt = "0"*n
        for xi in range(len(k[li])):
            point = k[li][xi]-1
            ltxt = ltxt[:point]+"1"+ltxt[point+1:]
        # print(ltxt)
        count = 0
        for xi in range(n):
            if txt[xi]=="1" and ltxt[xi]=="1":
                count += 1
        if count%2==p[li]:
            switch = True
        else:
            switch = False
            break
     li range(m) range m ltxt = "0"*n ltxt "0"*n "0" n for xi in range(len(k[li])):
            point = k[li][xi]-1
            ltxt = ltxt[:point]+"1"+ltxt[point+1:]
        # print(ltxt)
         xi range(len(k[li])) range len(k[li]) len k[li] k li point = k[li][xi]-1 point k[li][xi]-1 k[li][xi] [li] k li xi 1 ltxt = ltxt[:point]+"1"+ltxt[point+1:] ltxt ltxt[:point]+"1"+ltxt[point+1:] ltxt[:point]+"1" ltxt[:point] ltxt :point point "1" ltxt[point+1:] ltxt point+1: point+1 point 1 count = 0 count 0 for xi in range(n):
            if txt[xi]=="1" and ltxt[xi]=="1":
                count += 1
         xi range(n) range n if txt[xi]=="1" and ltxt[xi]=="1":
                count += 1
         txt[xi]=="1" and ltxt[xi]=="1" txt[xi]=="1" txt[xi] txt xi "1" ltxt[xi]=="1" ltxt[xi] ltxt xi "1" count += 1 count 1 if count%2==p[li]:
            switch = True
        else:
            switch = False
            break
     count%2==p[li] count%2 count 2 p[li] p li switch = True switch True switch = False switch False break if switch: countN  switch print(countN) print countN count = 0 0 count ksub = [int(xi) for xi in input().split()] [int(xi) for xi in input().split()] ksub txt = bin(Nnum)[2:] bin(Nnum)[2:] txt ltxt = ltxt[:point]+"1"+ltxt[point+1:] ltxt[:point]+"1"+ltxt[point+1:] ltxt switch = False False switch point = k[li][xi]-1 k[li][xi]-1 point txt = "0"*(n-len(txt))+txt "0"*(n-len(txt))+txt txt ltxt = "0"*n "0"*n ltxt k = [] [] k m = (int(xi) for xi in input().split()) (int(xi) for xi in input().split()) m count += 1 1 count switch = True True switch p = [int(xi) for xi in input().split()] [int(xi) for xi in input().split()] p n, m = (int(xi) for xi in input().split()) (int(xi) for xi in input().split()) n countN = 0 0 countN
n, m = (int(xi) for xi in input().split())
k = []
for xi in range(m):
    ksub = [int(xi) for xi in input().split()]
    k.append(ksub[1:])
p = [int(xi) for xi in input().split()]

# print(k)


countN = 0
for Nnum in range(2**n):
    txt = bin(Nnum)[2:]
    txt = "0"*(n-len(txt))+txt
    # print(txt)

    for li in range(m):
        ltxt = "0"*n
        for xi in range(len(k[li])):
            point = k[li][xi]-1
            ltxt = ltxt[:point]+"1"+ltxt[point+1:]
        # print(ltxt)
        count = 0
        for xi in range(n):
            if txt[xi]=="1" and ltxt[xi]=="1":
                count += 1
        if count%2==p[li]:
            switch = True
        else:
            switch = False
            break
    if switch: countN += 1

print(countN)
