import math





def number2bit(n):

    return int(math.pow(2, n - 1))





def count_bit(n):

    count = 0

    while n > 0:

        if n & 1 == 1:

            count += 1

        n >>= 1

    return count





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

lights = [set(tuple(map(int, input().split(' ')))[1:]) for _ in range(M)]

light_bits = [sum(map(number2bit, light)) for light in lights]

mods = tuple(map(int, input().split(' ')))



count = 0

for i in range(int(math.pow(2, N))):

    for j, light_bit in enumerate(light_bits):

        if count_bit(i & light_bit) % 2 != mods[j]:

            break

    else:

        count += 1



print(count)

import math





def number2bit(n):

    return int(math.pow(2, n - 1))





def count_bit(n):

    return bin(n)[2:].count('1')





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

lights = [tuple(map(int, input().split(' ')))[1:] for _ in range(M)]

light_bits = [sum(map(number2bit, light)) for light in lights]

mods = tuple(map(int, input().split(' ')))



count = 0

for i in range(int('1' + '0' * N, base=2)):

    for light_bit, mod in zip(light_bits, mods):

        if count_bit(i & light_bit) % 2 != mod:

            break

    else:

        count += 1



print(count)

import math


def number2bit(n):
    return int(math.pow(2, n - 1))


def count_bit(n):
    count = 0
    while n > 0:
        if n & 1 == 1:
            count += 1
        n >>= 1
    return count


N, M = list(map(int, input().split(" ")))
lights = [set(tuple(map(int, input().split(" ")))[1:]) for _ in range(M)]
light_bits = [sum(map(number2bit, light)) for light in lights]
mods = tuple(map(int, input().split(" ")))
count = 0
for i in range(int(math.pow(2, N))):
    for j, light_bit in enumerate(light_bits):
        if count_bit(i & light_bit) % 2 != mods[j]:
            break
    else:
        count += 1
print(count)

import math


def number2bit(n):
    return int(math.pow(2, n - 1))


def count_bit(n):
    return bin(n)[2:].count("1")


N, M = list(map(int, input().split(" ")))
lights = [tuple(map(int, input().split(" ")))[1:] for _ in range(M)]
light_bits = [sum(map(number2bit, light)) for light in lights]
mods = tuple(map(int, input().split(" ")))
count = 0
for i in range(int("1" + "0" * N, base=2)):
    for light_bit, mod in zip(light_bits, mods):
        if count_bit(i & light_bit) % 2 != mod:
            break
    else:
        count += 1
print(count)

-    count = 0 -    while n > 0: -        if n & 1 == 1: -            count += 1 -        n >>= 1 -    return count +    return bin(n)[2:].count("1") -lights = [set(tuple(map(int, input().split(" ")))[1:]) for _ in range(M)] +lights = [tuple(map(int, input().split(" ")))[1:] for _ in range(M)] -for i in range(int(math.pow(2, N))): -    for j, light_bit in enumerate(light_bits): -        if count_bit(i & light_bit) % 2 != mods[j]: +for i in range(int("1" + "0" * N, base=2)): +    for light_bit, mod in zip(light_bits, mods): +        if count_bit(i & light_bit) % 2 != mod: