310607: CF1859A. United We Stand

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

A. United We Standtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Given an array $a$ of length $n$, containing integers. And there are two initially empty arrays $b$ and $c$. You need to add each element of array $a$ to exactly one of the arrays $b$ or $c$, in order to satisfy the following conditions:

  • Both arrays $b$ and $c$ are non-empty. More formally, let $l_b$ be the length of array $b$, and $l_c$ be the length of array $c$. Then $l_b, l_c \ge 1$.
  • For any two indices $i$ and $j$ ($1 \le i \le l_b, 1 \le j \le l_c$), $c_j$ is not a divisor of $b_i$.

Output the arrays $b$ and $c$ that can be obtained, or output $-1$ if they do not exist.

Input

Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \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 $n$ ($2 \le n \le 100$) — the length of array $a$.

The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$) — the elements of array $a$.

Output

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

Otherwise, in the first line, output two integers $l_b$ and $l_c$ — the lengths of arrays $b$ and $c$ respectively.

In the second line, output $l_b$ integers $b_1, b_2, \ldots, b_{l_b}$ — the elements of array $b$.

In the third line, output $l_c$ integers $c_1, c_2, \ldots, c_{l_c}$ — the elements of array $c$.

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

ExampleInput
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
Output
-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 
Note

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

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

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

Output

题目大意:
给定一个长度为n的整数数组a。有两个初始为空的数组b和c。需要将数组a的每个元素恰好添加到数组b或c中的一个,以满足以下条件:
1. 数组b和c均非空。形式上,设lb为数组b的长度,lc为数组c的长度。则lb,lc≥1。
2. 对于任意两个指标i和j(1≤i≤lb,1≤j≤lc),cj不是bi的除数。
输出可以获得的数组b和c,如果不存在则输出-1。

输入输出数据格式:
输入:
第一行包含一个整数t(1≤t≤500)——测试用例的数量。
接下来是t个测试用例的描述。
每个测试用例的第一行包含一个整数n(2≤n≤100)——数组a的长度。
每个测试用例的第二行包含n个整数a1,a2,…,an(1≤ai≤10^9)——数组a的元素。

输出:
对于每个测试用例,如果没有解决方案,则输出一个整数-1。
否则,在第一行中,输出两个整数lb和lc——分别为数组b和c的长度。
在第二行中,输出lb个整数b1,b2,…,blb——数组b的元素。
在第三行中,输出lc个整数c1,c2,…,clc——数组c的元素。
如果有多个解决方案,输出其中任何一个。可以按任何顺序输出数组的元素。题目大意: 给定一个长度为n的整数数组a。有两个初始为空的数组b和c。需要将数组a的每个元素恰好添加到数组b或c中的一个,以满足以下条件: 1. 数组b和c均非空。形式上,设lb为数组b的长度,lc为数组c的长度。则lb,lc≥1。 2. 对于任意两个指标i和j(1≤i≤lb,1≤j≤lc),cj不是bi的除数。 输出可以获得的数组b和c,如果不存在则输出-1。 输入输出数据格式: 输入: 第一行包含一个整数t(1≤t≤500)——测试用例的数量。 接下来是t个测试用例的描述。 每个测试用例的第一行包含一个整数n(2≤n≤100)——数组a的长度。 每个测试用例的第二行包含n个整数a1,a2,…,an(1≤ai≤10^9)——数组a的元素。 输出: 对于每个测试用例,如果没有解决方案,则输出一个整数-1。 否则,在第一行中,输出两个整数lb和lc——分别为数组b和c的长度。 在第二行中,输出lb个整数b1,b2,…,blb——数组b的元素。 在第三行中,输出lc个整数c1,c2,…,clc——数组c的元素。 如果有多个解决方案,输出其中任何一个。可以按任何顺序输出数组的元素。

加入题单

上一题 下一题 算法标签: