from itertools import product



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



k = []

s = []

for _ in range(M):

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

    k.append(t[0])

    s.append(t[1:])



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



ans = sum(

    all(

        sum(

            t[j - 1]

            for j in s[i]

        ) % 2 == p[i]

        for i in range(M)

    )

    for t in product(list(range(2)), repeat=N)

)



print(ans)

from itertools import product



# 入力

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

k, s = list(zip(

    *(

        (int(k), list(map(int, s.split())))

        for _ in range(M)

        for k, s in [input().split(maxsplit=1)]

    )

))

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



# 全探索で解を求める

ans = sum(

    all(

        sum(t[j - 1] for j in S) % 2 == P

        for S, P in zip(s, p)

    )

    for t in product(list(range(2)), repeat=N)

)



# 出力

print(ans)

from itertools import product

N, M = list(map(int, input().split()))
k = []
s = []
for _ in range(M):
    t = list(map(int, input().split()))
    k.append(t[0])
    s.append(t[1:])
p = list(map(int, input().split()))
ans = sum(
    all(sum(t[j - 1] for j in s[i]) % 2 == p[i] for i in range(M))
    for t in product(list(range(2)), repeat=N)
)
print(ans)

from itertools import product

# 入力
N, M = list(map(int, input().split()))
k, s = list(
    zip(
        *(
            (int(k), list(map(int, s.split())))
            for _ in range(M)
            for k, s in [input().split(maxsplit=1)]
        )
    )
)
p = list(map(int, input().split()))
# 全探索で解を求める
ans = sum(
    all(sum(t[j - 1] for j in S) % 2 == P for S, P in zip(s, p))
    for t in product(list(range(2)), repeat=N)
)
# 出力
print(ans)

+# 入力 -k = [] -s = [] -for _ in range(M): -    t = list(map(int, input().split())) -    k.append(t[0]) -    s.append(t[1:]) +k, s = list( +    zip( +        *( +            (int(k), list(map(int, s.split()))) +            for _ in range(M) +            for k, s in [input().split(maxsplit=1)] +        ) +    ) +) +# 全探索で解を求める -    all(sum(t[j - 1] for j in s[i]) % 2 == p[i] for i in range(M)) +    all(sum(t[j - 1] for j in S) % 2 == P for S, P in zip(s, p)) +# 出力