from sys import stdin


def main():
    lines = stdin.readlines()
    N, M = map(int, lines[0].split())
    X = [sum(1 << int(j) - 1 for j in i.split()[1:]) for i in lines[1:-1]]
    Z = lines[-1].split()
    print(sum([1 for i in range(1 << N) if sum([1 for x, y in zip(X, Z) if bin(i & x).count("1") % 2 == int(y)]) == M]))
    return


main()
