# This source is wrong answer


def bits2tuple(n):
    ret = []
    i = 0
    while (1 << i) <= n:
        if n & (1 << i) != 0:
            ret.append(i)
        i += 1
    return tuple(ret)


def main():
    N, M = map(int, input().split())

    kM = []
    skM = []
    for _ in range(M):
        sk = list(map(int, input().split()))
        k = sk.pop(0)

        kM.append(k)
        skM.append(sk)

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

    ans = 0
    for bits in range(1, 1 << N):
        on_switch = list(map(lambda x: x + 1, bits2tuple(bits)))

        all_on = True
        for p, k, sk in zip(pM, kM, skM):
            if len(set(on_switch) & set(sk)) % 2 != p:
                all_on = False
                break

        if all_on:
            ans += 1

    print(ans)


main()
