AND Permutation

아직 제출이 없습니다시간 제한2초메모리 제한2048 MB

문제

You are given a sequence of nn distinct nonnegative integers a_1,a_2,,a_na\_1, a\_2, \ldots, a\_n.

For the given sequence, it is guaranteed that for all nonnegative numbers xx, if there is some ii such that a\_i \ \\&\ x = x, then there is a jj such that a_j=xa\_j = x. Here, \\& refers to the bitwise AND operator.

Find a permutation b_1,b_2,,b_nb\_1, b\_2, \ldots, b\_n of a_1,a_2,,a_na\_1, a\_2, \ldots, a\_n such that b\_i \ \\&\ a\_i = 0 for all ii. If there are multiple solutions, find any such permutation. It is guaranteed that a solution always exists.

입력

The first line of input contains an integer nn (1n<2181 \le n < 2^{18}), which is the number of integers in the permutation.

Each of the next nn lines contains an integer a_ia\_i (0a_i<2600 \le a\_i < 2^{60}), which is the input sequence, in order of ii. All of the a_ia\_i's are guaranteed to be distinct. For all nonnegative numbers xx, if there is some ii such that a\_i \ \\&\ x = x, then there is a jj such that a_j=xa\_j = x.

출력

Output nn lines, each containing a single integer, which are the b_ib\_i's, in order of ii.