B. Two Out of Three
3 seconds
512 megabytes
standard input
standard output
You are given an array a1,a2,…,an�1,�2,…,��. You need to find an array b1,b2,…,bn�1,�2,…,�� consisting of numbers 11, 22, 33 such that exactly two out of the following three conditions are satisfied:
- There exist indices 1≤i,j≤n1≤�,�≤� such that ai=aj��=��, bi=1��=1, bj=2��=2.
- There exist indices 1≤i,j≤n1≤�,�≤� such that ai=aj��=��, bi=1��=1, bj=3��=3.
- There exist indices 1≤i,j≤n1≤�,�≤� such that ai=aj��=��, bi=2��=2, bj=3��=3.
If such an array does not exist, you should report it.
Each test contains multiple test cases. The first line contains a single integer t� (1≤t≤500)(1≤�≤500) — the number of test cases. Each test case is described as follows.
The first line of each test case contains an integer n� (1≤n≤100)(1≤�≤100) — the length of the array a�.
The second line of each test case contains n� integers a1,a2,…,an�1,�2,…,�� (1≤ai≤100)(1≤��≤100) — the elements of the array a�.
For each test case, print -1 if there is no solution. Otherwise, print b1,b2,…,bn�1,�2,…,�� — an array consisting of numbers 11, 22, 33 that satisfies exactly two out of three conditions. If there are multiple possible answers, you can print any of them.
1 2 3 1 1 1 -1 3 2 2 1 -1 2 1 2 1 3 -1 1 1 2 2 1 2 2 3 3 -1 3 2 1 3 3 3 3 2 2 1 1 2 3 1 3 1 1 2