CF1859A.United We Stand

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

United We Stand

Given an array aa of length nn, containing integers. And there are two initially empty arrays bb and cc. You need to add each element of array aa to exactly one of the arrays bb or cc, in order to satisfy the following conditions:

  • Both arrays bb and cc are non-empty. More formally, let lbl_b be the length of array bb, and lcl_c be the length of array cc. Then lb,lc1l_b, l_c \ge 1.
  • For any two indices ii and jj (1ilb,1jlc1 \le i \le l_b, 1 \le j \le l_c), cjc_j is not a divisor of bib_i.

Output the arrays bb and cc that can be obtained, or output 1-1 if they do not exist.

Input

Each test consists of multiple test cases. The first line contains a single integer tt (1t5001 \le t \le 500) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer nn (2n1002 \le n \le 100) — the length of array aa.

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1ai1091 \le a_i \le 10^9) — the elements of array aa.

Output

For each test case, output a single integer 1-1 if a solution does not exist.

Otherwise, in the first line, output two integers lbl_b and lcl_c — the lengths of arrays bb and cc respectively.

In the second line, output lbl_b integers b1,b2,,blbb_1, b_2, \ldots, b_{l_b} — the elements of array bb.

In the third line, output lcl_c integers c1,c2,,clcc_1, c_2, \ldots, c_{l_c} — the elements of array cc.

If there are multiple solutions, output any of them. You can output the elements of the arrays in any order.

Note

In the first test case, a solution does not exist.

In the second test case, we can obtain b=[1,3,5]b = [1, 3, 5] and c=[2,4]c = [2, 4]. Then elements 22 and 44 do not divide elements 1,31, 3 and 55.

In the fifth test case, we can obtain b=[4,8,4]b = [4, 8, 4] and c=[12,12]c = [12, 12].

Samples

5
3
2 2 2
5
1 2 3 4 5
3
1 3 5
7
1 7 7 2 9 1 4
5
4 8 12 12 4
-1
3 2
1 3 5 
2 4 
1 2
1 
3 5 
2 5
1 1 
2 4 7 7 9 
3 2
4 8 4 
12 12 

在线编程 IDE

建议全屏模式获得最佳体验