Problem: Alexander is a well-known programmer. Today he decided to finally go out and play football, but with the first hit he left a dent on the new Rolls-Royce of the wealthy businessman Big Vova. Vladimir has recently opened a store on the popular online marketplace "Zmey-Gorynych", and offers Alex a job: if he shows his programming skills by solving a task, he'll work as a cybersecurity specialist. Otherwise, he'll be delivering some doubtful products for the next two years.
You're given positive integers . Using each of them exactly at once, you're to make such sequence that sequence is lexicographically maximal, where - the greatest common divisor of the first elements of .
Alexander is really afraid of the conditions of this simple task, so he asks you to solve it.
A sequence is lexicographically smaller than a sequence if and only if one of the following holds:
- is a prefix of , but ;
- in the first position where and differ, the sequence has a smaller element than the corresponding element in .
Input Format: Each test contains multiple test cases. The first line contains the number of test cases (). Description of the test cases follows.
The first line of each test case contains a single integer () — the length of the sequence .
The second line of each test case contains integers () — the sequence .
It is guaranteed that the sum of over all test cases does not exceed .
Output Format: For each test case output the answer in a single line — the desired sequence . If there are multiple answers, print any.
Note: In the first test case of the example, there are only two possible permutations — and : for the first one , for the second one .
In the third test case of the example, number should be the first in , and , , so the second number of should be .
In the seventh test case of the example, first four numbers pairwise have a common divisor (a power of two), but none of them can be the first in the optimal permutation .