#P5316. 恋恋的数学题

恋恋的数学题

Description

The problem Lianlian is working on now is very simple: there are k (2k4)k \space (2\leq k\leq 4) numbers. Lianlian does not know what they are, but she knows the pairwise greatest common divisors and least common multiples of these numbers.

As usual, Lianlian really wants to reconstruct those kk numbers, but now she needs to pretend she cannot do it, so she hands the problem to you. If you solve it successfully, Lianlian will cheer for you like crazy behind your back.

Input Format

The first line contains two integers TT and kk.

The next 2T2T lines contain TT test cases, and each test case consists of two lines.

The first line contains k(k1)2\frac{k(k-1)}2 integers, representing the pairwise greatest common divisors of the kk unknown numbers, in arbitrary order.

The second line contains k(k1)2\frac{k(k-1)}2 integers, representing the pairwise least common multiples of the kk unknown numbers, in arbitrary order.

Output Format

Output TT lines. Each line contains kk numbers separated by spaces, representing any one set of answers that matches the given data.

1 3
4 6 2
48 144 36
16 12 18
2 4
4 2 4 6 4 2
48 144 16 36 12 36
1 1 1 1 2 1 
56 63 70 72 40 90 
16 12 18 4
7 8 9 10

Hint

It is guaranteed that for odd-numbered test points, the first line (the gcd line) is all 11.

Test Point ID kk Input Integers Do Not Exceed
1,2 2 100100
3,4 10001000
5,6 10710^7
7,8 3 100100
9,10 10710^7
11,12 101410^{14}
13,14 4 100100
15,16 10710^7
17,18 101410^{14}
19,20 101810^{18}

It is guaranteed that the testdata has a solution, and T5T\leq 5.

The SPJ scores according to the correct ratio within each test case, but if TLE, RE, etc. causes no output, you will get zero points.

Translated by ChatGPT 5