def fbit(k,n):

    t=[]

    kk=k

    for i in range(n):

        t.append(kk%2)

        kk=int(kk/2)

    return t        



n,m=list(map(int,input().split()))

s=[]

for i in range(m):

    si=[]

    for j in range(n):

        si.append(0)

    s.append(si)

    

for j in range(m):

    str=input().split()

    k_m=int(str[0])

    for k in range(k_m):

        ii=int(str[k+1])-1

        s[j][ii]=1



str=input().split()

p=[]

for k in range(m):

    p.append(int(str[k]))



icnt=0

for k in range(2**n):

    icnt2=0

    bit=fbit(k,n)

    for im in range(m):

        icnt3=0

        for kn in range(n):

            icnt3=icnt3+bit[kn]*s[im][kn]

        if icnt3%2==p[im]:

            icnt2=icnt2+1

    if icnt2==m:

        icnt=icnt+1

print(icnt)       


import itertools



n,m=list(map(int,input().split()))

ks=[]

for i in range(m):

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

    ks.append(ksi)

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

    

icnt=0

for i in itertools.product([0,1], repeat=n):

    yn=""

    mcnt=0

    for j in range(m):

        ksum=0

        for k in range(ks[j][0]):

            if i[ks[j][k+1]-1]==1:

                ksum+=1

        if ksum%2==p[j]:

            mcnt+=1

    if mcnt==m:

        icnt+=1

#    print(icnt,mcnt,i)

print(icnt)

def fbit(k, n):
    t = []
    kk = k
    for i in range(n):
        t.append(kk % 2)
        kk = int(kk / 2)
    return t


n, m = list(map(int, input().split()))
s = []
for i in range(m):
    si = []
    for j in range(n):
        si.append(0)
    s.append(si)
for j in range(m):
    str = input().split()
    k_m = int(str[0])
    for k in range(k_m):
        ii = int(str[k + 1]) - 1
        s[j][ii] = 1
str = input().split()
p = []
for k in range(m):
    p.append(int(str[k]))
icnt = 0
for k in range(2**n):
    icnt2 = 0
    bit = fbit(k, n)
    for im in range(m):
        icnt3 = 0
        for kn in range(n):
            icnt3 = icnt3 + bit[kn] * s[im][kn]
        if icnt3 % 2 == p[im]:
            icnt2 = icnt2 + 1
    if icnt2 == m:
        icnt = icnt + 1
print(icnt)

import itertools

n, m = list(map(int, input().split()))
ks = []
for i in range(m):
    ksi = list(map(int, input().split()))
    ks.append(ksi)
p = list(map(int, input().split()))
icnt = 0
for i in itertools.product([0, 1], repeat=n):
    yn = ""
    mcnt = 0
    for j in range(m):
        ksum = 0
        for k in range(ks[j][0]):
            if i[ks[j][k + 1] - 1] == 1:
                ksum += 1
        if ksum % 2 == p[j]:
            mcnt += 1
    if mcnt == m:
        icnt += 1
#    print(icnt,mcnt,i)
print(icnt)

-def fbit(k, n): -    t = [] -    kk = k -    for i in range(n): -        t.append(kk % 2) -        kk = int(kk / 2) -    return t - +import itertools -s = [] +ks = [] -    si = [] -    for j in range(n): -        si.append(0) -    s.append(si) -for j in range(m): -    str = input().split() -    k_m = int(str[0]) -    for k in range(k_m): -        ii = int(str[k + 1]) - 1 -        s[j][ii] = 1 -str = input().split() -p = [] -for k in range(m): -    p.append(int(str[k])) +    ksi = list(map(int, input().split())) +    ks.append(ksi) +p = list(map(int, input().split())) -for k in range(2**n): -    icnt2 = 0 -    bit = fbit(k, n) -    for im in range(m): -        icnt3 = 0 -        for kn in range(n): -            icnt3 = icnt3 + bit[kn] * s[im][kn] -        if icnt3 % 2 == p[im]: -            icnt2 = icnt2 + 1 -    if icnt2 == m: -        icnt = icnt + 1 +for i in itertools.product([0, 1], repeat=n): +    yn = "" +    mcnt = 0 +    for j in range(m): +        ksum = 0 +        for k in range(ks[j][0]): +            if i[ks[j][k + 1] - 1] == 1: +                ksum += 1 +        if ksum % 2 == p[j]: +            mcnt += 1 +    if mcnt == m: +        icnt += 1 +#    print(icnt,mcnt,i)