P19242 [CodeChef] ADJHATE
普及
题目描述

Read problems statements in [Russian] and [Bengali].

An array is called lovely if the sum of absolute differences of each adjacent pair of elements is odd; formally, the array S of size m is lovely if $\sum_{i=1}^{m-1} |S_{i}-S_{i+1}|$ is odd.

You are given an array A of N integers. You need to reorder the array in any manner such that the array becomes lovely. If there is no reordering operation that makes the array lovely, output -1.

------ Input Format ------

  • The first line contains an integer T denoting the number of test cases. The T test cases then follow.
  • The first line of each test case contains an integer N.
  • The second line of each test case contains $N space-separated integers A_{1}, A_{2}, \dots, A_{N}$.

------ Output Format ------

For each test case, print a single line containing N integers denoting the modified array which is lovely, or -1 if it is not possible.

------ Constraints ------

$1 ≤T ≤1000$
$2 ≤N ≤500$
$1 ≤A_{i} ≤10^{6}$

----- Sample Input 1 ------
2
6
3 7 10 1 2 12
2
1 3

----- Sample Output 1 ------
1 2 3 10 7 12
-1

----- explanation 1 ------
- For the first test case, the sum is $|1-2| + |2-3| + |3-10| + |10-7| + |7-12| = 1+1+7+3+5 = 17$ which is odd.

  • For the second test case, $|1-3| = 2$ which is even. There is no array that can satisfy the above condition.
输入格式

见题面

输出格式

见题面

样例输入
2 6 3 7 10 1 2 12 2 1 3
样例输出
1 2 3 10 7 12 -1