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()
    ans = 0
    for i in range(1, 1 << N):
        tmp = 0
        for x, y in zip(X, Z):
            if bin(i & x).count("1") % 2 == int(y):
                tmp += 1
        if tmp == M:
            ans += 1
    print(ans)

    return


main()
