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

s=[list(map(int,input().split())) for _ in range(m)]

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

ans=0

for i in range(2**n):

    b=0

    for j in range(m):

        a=0

        for k in s[j][1:]:

            if (i>>(k-1))&1:

                a+=1

        if a%2==p[j]:

            a+=1

            b+=1

    if b==m:        

        ans+=1

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

s=[list(map(int,input().split())) for _ in range(m)]

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

a=0

for i in range(2**n):

    a+=all(sum((i>>(k-1))&1 for k in s[j][1:])%2==p[j] for j in range(m))

print(a)
n, m = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
ans = 0
for i in range(2**n):
    b = 0
    for j in range(m):
        a = 0
        for k in s[j][1:]:
            if (i >> (k - 1)) & 1:
                a += 1
        if a % 2 == p[j]:
            a += 1
            b += 1
    if b == m:
        ans += 1
print(ans)

n, m = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(m)]
(*p,) = list(map(int, input().split()))
a = 0
for i in range(2**n):
    a += all(sum((i >> (k - 1)) & 1 for k in s[j][1:]) % 2 == p[j] for j in range(m))
print(a)

-p = list(map(int, input().split())) -ans = 0 +(*p,) = list(map(int, input().split())) +a = 0 -    b = 0 -    for j in range(m): -        a = 0 -        for k in s[j][1:]: -            if (i >> (k - 1)) & 1: -                a += 1 -        if a % 2 == p[j]: -            a += 1 -            b += 1 -    if b == m: -        ans += 1 -print(ans) +    a += all(sum((i >> (k - 1)) & 1 for k in s[j][1:]) % 2 == p[j] for j in range(m)) +print(a)