# coding: utf-8
import itertools

N, M = list(map(int, input().split(" ")))
k = []
for _ in range(M):
    k.append(list(map(int, input().split(" "))))
p = list(map(int, input().split(" ")))

bits = itertools.product(["on", "off"], repeat=N)

def tento(bit, k, p):
    for i, pi in enumerate(p):
        ki = list(k[i])
        tmp = 0
        for kij in ki[1:]:
            if bit[kij-1] == "on":
                tmp += 1
        if tmp % 2 != pi:
            return False
    return True

res = 0
for bit in bits:
    if tento(bit, k, p):
        res+=1
print(res) import itertools itertools N, M = list(map(int, input().split(" "))) N list(map(int, input().split(" "))) list map(int, input().split(" ")) map int input().split(" ") ().split () input split " " M k = [] k [] for _ in range(M):
    k.append(list(map(int, input().split(" ")))) _ range(M) range M k.append(list(map(int, input().split(" ")))) k.append k append list(map(int, input().split(" "))) list map(int, input().split(" ")) map int input().split(" ") ().split () input split " " p = list(map(int, input().split(" "))) p list(map(int, input().split(" "))) list map(int, input().split(" ")) map int input().split(" ") ().split () input split " " bits = itertools.product(["on", "off"], repeat=N) bits itertools.product(["on", "off"], repeat=N) itertools.product itertools product ["on", "off"] "on" "off" repeat=N repeat N def tento(bit, k, p):
    for i, pi in enumerate(p):
        ki = list(k[i])
        tmp = 0
        for kij in ki[1:]:
            if bit[kij-1] == "on":
                tmp += 1
        if tmp % 2 != pi:
            return False
    return True tento for i, pi in enumerate(p):
        ki = list(k[i])
        tmp = 0
        for kij in ki[1:]:
            if bit[kij-1] == "on":
                tmp += 1
        if tmp % 2 != pi:
            return False
     i pi enumerate(p) enumerate p ki = list(k[i]) ki list(k[i]) list k[i] k i tmp = 0 tmp 0 for kij in ki[1:]:
            if bit[kij-1] == "on":
                tmp += 1
         kij ki[1:] ki 1: 1 if bit[kij-1] == "on":
                tmp += 1
         bit[kij-1] == "on" bit[kij-1] bit kij-1 kij 1 "on" tmp += 1 tmp 1 if tmp % 2 != pi:
            return False
     tmp % 2 != pi tmp % 2 tmp 2 pi return False False return True True bit bit k k p p res = 0 res 0 for bit in bits:
    if tento(bit, k, p):
        res+=1 bit bits if tento(bit, k, p):
        res+=1 tento(bit, k, p) tento bit k p res+=1 res 1 print(res) print res res = 0 0 res bits = itertools.product(["on", "off"], repeat=N) itertools.product(["on", "off"], repeat=N) bits res+=1 1 res N, M = list(map(int, input().split(" "))) list(map(int, input().split(" "))) N M = list(map(int, input().split(" "))) list(map(int, input().split(" "))) M k = [] [] k def tento(bit, k, p):
    for i, pi in enumerate(p):
        ki = list(k[i])
        tmp = 0
        for kij in ki[1:]:
            if bit[kij-1] == "on":
                tmp += 1
        if tmp % 2 != pi:
            return False
    return True def tento(bit, k, p):
    for i, pi in enumerate(p):
        ki = list(k[i])
        tmp = 0
        for kij in ki[1:]:
            if bit[kij-1] == "on":
                tmp += 1
        if tmp % 2 != pi:
            return False
    return True tento p = list(map(int, input().split(" "))) list(map(int, input().split(" "))) p
# coding: utf-8
import itertools

N, M = list(map(int, input().split(" ")))
k = []
for _ in range(M):
    k.append(list(map(int, input().split(" "))))
p = list(map(int, input().split(" ")))

bits = itertools.product(["on", "off"], repeat=N)

def tento(bit, k, p):
    for i, pi in enumerate(p):
        ki = list(k[i])
        tmp = 0
        for kij in ki[1:]:
            if bit[kij-1] == "on":
                tmp += 1
        if tmp % 2 != pi:
            return False
    return True

res = 0
for bit in bits:
    if tento(bit, k, p):
        res+=1
print(res)