CF1859A.United We Stand

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

输入格式

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 .

输出格式

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.

输入输出样例

  • 输入#1

    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

    -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

说明/提示

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] .

首页