##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
3
2 5 2
4 7 0 1 6
7 3 5 6 1 0 2 7
0 7
0 0 7 7
0 0 0 3 7 7 7
You are given an array of integers of length .
In one operation, you may choose two indices and () and simultaneously replace:
Here and denote bitwise AND and bitwise OR, respectively (the right-hand sides use the values of and before the operation).
Your task is to obtain the lexicographically smallest array that can be reached after performing any number of operations (possibly zero), and output that array.
where is the lexicographically smallest array achievable from using the allowed operation.
Apply the operation on indices 1 and 2, the array becomes: .
Apply the operation on indices 1 and 2, the array becomes: .
Apply the operation on indices 2 and 3, the array becomes: .
Apply the operation on indices 2 and 4, the array becomes: .
Apply operations on these pairs (in this order): , , , and .