Lecographically Maximum
시간 제한1초메모리 제한1024 MB
N개의 정수에서 임의의 두 위치의 k번째 비트를 맞바꿀 수 있을 때, 도달 가능한 배열 중 사전순으로 최대인 배열을 구한다.
문제
A list of integers is stored in the memory of an electronic device. This device has a very peculiar operation available: bit swapping between numbers. More precisely, given integers , and , this operation swaps the -th bit of the integer with the -th bit of the integer (and vice-versa).
Very interesting phenomena can occur when performing this operation one or more times, such as obtaining numbers that did not even belong to the original list, or even numbers larger or smaller than all the original elements.
For this problem, we are interested in using the operation as many times as necessary to change the list of numbers so that the resulting list is the lexicographically maximum, that is, that is the largest possible, that is the largest possible among the possible solutions that maximize , and so on.
입력
The first line of input contains an integer () and the second line contains integers, separated by spaces, corresponding to the list ().
출력
Your program should print a single line containing space-separated integers corresponding to the lexicographically maximum obtainable sequence.