You are given an array $$$A$$$ of length $$$n$$$ consisting only of numbers $$$0$$$ and $$$1$$$. You may obtain another array $$$A'$$$ by performing a cyclic rotation of $$$A$$$ by any number of positions (possibly zero).
A cyclic rotation shifts elements of an array circularly. For example, rotating $$$[1, 0, 1, 1, 0]$$$ gives: $$$$$$ [1, 0, 1, 1, 0], \; [0, 1, 1, 0, 1], \; [1, 1, 0, 1, 0], \; [1, 0, 1, 0, 1], \; [0, 1, 0, 1, 1] $$$$$$
Define an array $$$B$$$ as follows: $$$$$$B[i] = A[i] \oplus A'[i] \quad \text{for all } 0 \le i \lt n$$$$$$ where $$$\oplus$$$ denotes the bitwise XOR operation.
An array $$$X$$$ is said to be lexicographically larger than an array $$$Y$$$ if:
Your task is to determine the lexicographically maximum binary array $$$B$$$ that can be obtained among all possible cyclic rotations of $$$A$$$.
The first line of the input contains a single integer $$$t$$$ $$$(1 \le t \le 10^4)$$$ — the number of test cases.
Each test case consists of two lines:
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.
For each test case, output $$$n$$$ integers separated by spaces — the lexicographically maximum binary array $$$B$$$.
241 1 0 051 0 1 1 0
1 1 1 11 1 1 0 1
Consider the first test case where $$$A = [1, 1, 0, 0]$$$. The array has 4 cyclic rotations: $$$$$$ [1, 1, 0, 0], \; [1, 0, 0, 1], \; [0, 0, 1, 1], \; [0, 1, 1, 0]. $$$$$$
Calculating $$$B$$$ for each rotation:
Among all possible rotations $$$A'$$$, the lexicographically maximum $$$B$$$ is $$$[1, 1, 1, 1]$$$.
| Name |
|---|


