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

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

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

ans = 0



for i in range(1<<N):

    on = 0

    onoff = bin(i)[2:].zfill(N)

    for j, switches in enumerate(lights):

        if sum(onoff[s-1] == '1' for s in switches[1:]) % 2 == p[j]:

            on += 1

    if on == M:

        ans += 1



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

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

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

ans = 0



for i in range(1<<N):

    for j,lst in enumerate(connected):

        count = 0

        for s in lst[1:]:

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

                count += 1

        if count % 2 != p[j]:

            break

    else:

        ans += 1



print(ans)

N, M = list(map(int, input().split()))
lights = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))
ans = 0
for i in range(1 << N):
    on = 0
    onoff = bin(i)[2:].zfill(N)
    for j, switches in enumerate(lights):
        if sum(onoff[s - 1] == "1" for s in switches[1:]) % 2 == p[j]:
            on += 1
    if on == M:
        ans += 1
print(ans)

N, M = list(map(int, input().split()))
connected = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))
ans = 0
for i in range(1 << N):
    for j, lst in enumerate(connected):
        count = 0
        for s in lst[1:]:
            if (i >> (s - 1)) & 1:
                count += 1
        if count % 2 != p[j]:
            break
    else:
        ans += 1
print(ans)

-lights = [list(map(int, input().split())) for _ in range(M)] +connected = [list(map(int, input().split())) for _ in range(M)] -    on = 0 -    onoff = bin(i)[2:].zfill(N) -    for j, switches in enumerate(lights): -        if sum(onoff[s - 1] == "1" for s in switches[1:]) % 2 == p[j]: -            on += 1 -    if on == M: +    for j, lst in enumerate(connected): +        count = 0 +        for s in lst[1:]: +            if (i >> (s - 1)) & 1: +                count += 1 +        if count % 2 != p[j]: +            break +    else: