Two integers $*x*$ and $*y*$ are compatible, if the result of their bitwise "AND" equals zero, that is, $*a*$ $&$ $*b* = 0$. For example, numbers $90$ $(1011010_{2})$ and $36$ $(100100_{2})$ are compatible, as $1011010_{2}$ $&$ $100100_{2} = 0_{2}$, and numbers $3$ $(11_{2})$ and $6$ $(110_{2})$ are not compatible, as $11_{2}$ $&$ $110_{2} = 10_{2}$.
You are given an array of integers $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$. Your task is to find the following for each array element: is this element compatible with some other element from the given array? If the answer to this question is positive, then you also should find any suitable element.
Input
The first line contains an integer $*n*$ ($1 ≤ *n* ≤ 10^{6}$) — the number of elements in the given array. The second line contains $*n*$ space-separated integers $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$ ($1 ≤ *a*_{*i*} ≤ 4·10^{6}$) — the elements of the given array. The numbers in the array can coincide.
Output
Print $*n*$ integers $*ans*_{*i*}$. If $*a*_{*i*}$ isn't compatible with any other element of the given array $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$, then $*ans*_{*i*}$ should be equal to -1. Otherwise $*ans*_{*i*}$ is any such number, that $*a*_{*i*}$ $&$ $*ans*_{*i*} = 0$, and also $*ans*_{*i*}$ occurs in the array $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$.
样例
2
90 36
36 90
4
3 6 3 6
-1 -1 -1 -1
5
10 6 9 8 2
-1 8 2 2 8
题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。