import itertools


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

lights = []
for i in range(M):
    lights.append([int(x) - 1 for x in input().split()[1:]])

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

is_ok = 0
for mode in itertools.product((0, 1), repeat=M):
    mode = list(mode)
    on = 0
    for i, light in enumerate(lights):
        sw = 0
        for x in light:
            sw += mode[x]
        if sw % 2 == patterns[i]:
            on += 1
    if on == M:
        is_ok += 1

print(is_ok)
