N,M = list(map(int,input().split()))

in_M =[[]]*M 

for m in range(M):

    in_M[m] = list(map(int,input().split()))

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



all_on_cnt = 0

for i in range(2**N):

    switch = [0]*N

    for j in range(N):

        if((i>>j) & 1): # iをj回右シフトさせ末尾をみる

            switch[j] = 1

    

    for j in range(M):

        total = 0

        for l in range(1,in_M[j][0]+1):

            total += switch[in_M[j][l]-1]

        if total%2 != out_M[j]:

            break

    else:

        all_on_cnt += 1

          

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

swi = []

for _ in range(m):

    k, *sss = list(map(int,input().split()))

    t = 0

    for s in sss:

        t += 1 << (s-1)

    swi.append(t)

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



ans = 0

for bit in range(1<<n):

    for s,p in zip(swi,ppp):

        t = bit&s

        c = bin(t).count("1") % 2

        if c != p:

            break

    else:

        ans += 1

print(ans)
N, M = list(map(int, input().split()))
in_M = [[]] * M
for m in range(M):
    in_M[m] = list(map(int, input().split()))
out_M = list(map(int, input().split()))
all_on_cnt = 0
for i in range(2**N):
    switch = [0] * N
    for j in range(N):
        if (i >> j) & 1:  # iをj回右シフトさせ末尾をみる
            switch[j] = 1
    for j in range(M):
        total = 0
        for l in range(1, in_M[j][0] + 1):
            total += switch[in_M[j][l] - 1]
        if total % 2 != out_M[j]:
            break
    else:
        all_on_cnt += 1
print(all_on_cnt)

n, m = list(map(int, input().split()))
swi = []
for _ in range(m):
    k, *sss = list(map(int, input().split()))
    t = 0
    for s in sss:
        t += 1 << (s - 1)
    swi.append(t)
ppp = list(map(int, input().split()))
ans = 0
for bit in range(1 << n):
    for s, p in zip(swi, ppp):
        t = bit & s
        c = bin(t).count("1") % 2
        if c != p:
            break
    else:
        ans += 1
print(ans)

-N, M = list(map(int, input().split())) -in_M = [[]] * M -for m in range(M): -    in_M[m] = list(map(int, input().split())) -out_M = list(map(int, input().split())) -all_on_cnt = 0 -for i in range(2**N): -    switch = [0] * N -    for j in range(N): -        if (i >> j) & 1:  # iをj回右シフトさせ末尾をみる -            switch[j] = 1 -    for j in range(M): -        total = 0 -        for l in range(1, in_M[j][0] + 1): -            total += switch[in_M[j][l] - 1] -        if total % 2 != out_M[j]: +n, m = list(map(int, input().split())) +swi = [] +for _ in range(m): +    k, *sss = list(map(int, input().split())) +    t = 0 +    for s in sss: +        t += 1 << (s - 1) +    swi.append(t) +ppp = list(map(int, input().split())) +ans = 0 +for bit in range(1 << n): +    for s, p in zip(swi, ppp): +        t = bit & s +        c = bin(t).count("1") % 2 +        if c != p: -        all_on_cnt += 1 -print(all_on_cnt) +        ans += 1 +print(ans)