def solve():
    N, M = map(int, input().split())
    K = [sum([2 ** (int(i) - 1) for i in input().split()]) for _ in
              range(M)]
    P = [int(i) for i in input().split()]
    count = 0
    for i in range(2 ** N):
        for k, p in zip(K, P):
            if bin(k & i).count('1') % 2 != p:
                break
        else:
            count += 1
            # print(bin(i))

    print(count)


if __name__ == '__main__':
    solve()
