def METHOD_NAME(max_n=64, random_state=None, level=None):
    if max_n == 1:
        assert level is None or level == 0
        return 0, 0, "B"
    elif max_n < 1:
        raise ValueError("max_n must be a positive integer")
    if random_state is None:
        random_state = np.random.RandomState()
    max_l = int(np.log2(max_n))
    form = f"%0{max_l}d"
    num10 = random_state.randint(0, high=max_n)
    num2 = form % int(bin(num10)[2:])  # the slice clips the '0b' prefix
    if level is None:
        level = random_state.randint(0, high=max_l)
    if level > 0:
        my_block = f"{num2[:-level]}:{num2[-level:]}"
    else:
        my_block = num2
    my_block = "B" + my_block
    return num10, level, my_block