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

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

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



ans = 0

for bit in range(2 ** N):

    ons = set([i + 1 for i in range(N) if bit >> i & 1])

    flg = True

    for i in range(M):

        k, *s = X[i]

        p = P[i]

        flg &= len(set(s) & ons) % 2 == p

    ans += int(flg)

    

print(ans)



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

K = []

X = []

for _ in range(M):

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

    K.append(k)

    X.append(x)

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



ans = 0

for bit in range(2 ** N):

    light_on = [False] * M

    for i in range(M):

        tmp = 0

        for s in X[i]:

            tmp += bit >> (s - 1) & 1

        light_on[i] = tmp % 2 == P[i]



    ans += all(light_on)



print(ans)

N, M = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(M)]
P = list(map(int, input().split()))
ans = 0
for bit in range(2**N):
    ons = set([i + 1 for i in range(N) if bit >> i & 1])
    flg = True
    for i in range(M):
        k, *s = X[i]
        p = P[i]
        flg &= len(set(s) & ons) % 2 == p
    ans += int(flg)
print(ans)

N, M = list(map(int, input().split()))
K = []
X = []
for _ in range(M):
    k, *x = list(map(int, input().split()))
    K.append(k)
    X.append(x)
P = list(map(int, input().split()))
ans = 0
for bit in range(2**N):
    light_on = [False] * M
    for i in range(M):
        tmp = 0
        for s in X[i]:
            tmp += bit >> (s - 1) & 1
        light_on[i] = tmp % 2 == P[i]
    ans += all(light_on)
print(ans)

-X = [list(map(int, input().split())) for _ in range(M)] +K = [] +X = [] +for _ in range(M): +    k, *x = list(map(int, input().split())) +    K.append(k) +    X.append(x) -    ons = set([i + 1 for i in range(N) if bit >> i & 1]) -    flg = True +    light_on = [False] * M -        k, *s = X[i] -        p = P[i] -        flg &= len(set(s) & ons) % 2 == p -    ans += int(flg) +        tmp = 0 +        for s in X[i]: +            tmp += bit >> (s - 1) & 1 +        light_on[i] = tmp % 2 == P[i] +    ans += all(light_on)