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

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

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

ret = 0

for b in range(1 << n):

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

        ret += 1

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

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

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

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

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

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