You are given a sequence of distinct nonnegative integers
.
For the given sequence, it is guaranteed that for all
nonnegative numbers ,
if there is some such
that , then there is a such that . Here, refers to the bitwise
AND operator.
Find a permutation of such that for all
. If there are multiple
solutions, find any such permutation. It is guaranteed that a
solution always exists.
Input
The first line of input contains an integer (), which is the number of integers in
the permutation.
Each of the next
lines contains an integer (), which is the input sequence, in order of
. All of the
’s are guaranteed to
be distinct. For all nonnegative numbers , if there is some such that , then there is
a such that
.
Output
Output lines, each
containing a single integer, which are the ’s, in order of .
Sample Input 1 |
Sample Output 1 |
6
0
1
4
5
2
6
|
4
6
0
2
5
1
|