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

s=[]

for _ in range(m):

    _,*t=list(map(int,input().split()))

    s.append(t)

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

a=0

for i in range(2**n):

    f=1

    for j in range(m):

        g=1

        g&=(sum([int(bin(i>>(u-1)),2) for u in s[j]])%2==p[j])

        f&=g

    a+=f

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

s=[]

for _ in range(m):_,*t=list(map(int,input().split()));s.append(t)

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

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

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

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