from typing import Set


def candidates_to_bits(candidates: Set[int]) -> int:
    """
    Convert a candidates set into its bits representation
    The bits are in big endian order

    >>> bin(candidates_to_bits({1, 2, 3, 6, 7}))
    '0b1100111'

    >>> bin(candidates_to_bits({6, 9}))
    '0b100100000'
    """
    bits = 0
    for candidate in candidates:
        bits ^= 1 << (candidate - 1)

    return bits