F. Nastya and Decryption
Nastya recently joined a decryption club. After breezing through the initial tasks, she was presented with a more challenging cipher. This cipher involves two arrays of positive integers, with lengths and , respectively. These arrays are encrypted into a table of size , where each element represents the greatest common divisor (GCD) of the numbers and from the arrays.
Nastya has been given the table and needs to determine any two original arrays of positive integers, where each number is no greater than , that could have been encrypted to produce this table. Your task is to assist her in finding these arrays.
Input
The first line contains two integers and () — the lengths of the two arrays.
The following lines each contain integers () — the elements of the table .
Output
The first line should output integers () — the elements of the first array.
The second line should output integers () — the elements of the second array.
If there are multiple valid solutions, you may output any of them.
If no solution is possible, output on a single line.