N, M = [int(i) for i in input().split()]
masks = [0] * M

for i in range(M):
    inp = [int(j) for j in input().split()]
    k = inp[0]
    s = inp[1:]
    b = [0] * M
    for j in range(M):
        b[j] = "1" if j+1 in s else "0"
    masks[i] = int("".join(reversed(b)), 2)
    # print(list(reversed(b)))

ps = [int(p) for p in input().split()]
s = 0

for t in range(2**N):
    for i in range(M):
        v = masks[i] & t
        # print("i:", i)
        # print("t: {}\nm: {}\nv: {}\n\n".format(format(t, "b"), format(masks[i], "b"), format(v, "b")))
        if format(v, "b").count("1") % 2 != ps[i]:
            break
    else:
        # print("count")
        s += 1

print(s)