#Lutece1302. Good Water Problem
Good Water Problem
Migrated from Lutece 1302 Good Water Problem
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
Given integers, you are allowed to change the numbers in a sequence of steps.
In each step, you can:
Select two numbers and .
Erase and .
Write two new integers onto the blackboard: and .
(Above, denotes the greatest common divisor and the least common multiple of and .)
Your goal is to maximize the maximum number. Under that circumstance, try to maximize the second largest number, the third largest number, and so on.
Input
The first line contains an integer , denoting the number of the test cases.
For each case, there is an integer .
The next line contains integers. Let denotes the number.
Output
Output numbers, the answer mod , denoting the largest number, the second largest number, and so on.
Samples
1
4
999983 999983 999979 32
783787438 999983 1 1
Resources
The 14th UESTC Programming Contest Preliminary