logo AlgoBeat OnlineJudge
登录 注册

#216098. [ICPC 2021 NAC] AND Permutation

内存限制:2048 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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.

输入格式

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 lines, each containing a single integer, which are the 's, in order of .

样例

样例输入 1

6
0
1
4
5
2
6

样例输出 1

4
6
0
2
5
1