Given a set of n integers, you have to take a subset such that the set is multiple free. That means you have to take a subset such that if you pick any two elements p, q from the subset, then p is not a multiple of q or q is not a multiple of p.
For example, let the set be {2, 5, 10, 8}, then your subset can be {2} or {10} or {5, 8}, etc. But you can't take {2, 8} since 8 is multiple of 2, or you can't take {10, 5} since 10 is multiple of 5.
Now your task is to find such a subset with maximum number of elements. There can be several solutions with maximum number of elements. In such case, we break the tie by the following:
Let {a1, a2, a3 ... am} be a solution and {b1, b2, b3 ... bm} be another solution where ai < ai+1 and bi < bi+1 for i = 1 to m-1. Then {a1, a2, a3 ... am} is the result if
ai < bi or
ai = bi and ai+1 < bi+1 or
ai = bi and ai+1 = bi+1 and ai+2 < bi+2 or
...
For example, let one solution be {3, 5} and another solution be {3, 10}, then we want {3, 5} as our result.
Input
Input starts with an integer T (≤ 200), denoting the number of test cases.
Each case starts with a line containing an integer n (1 ≤ n ≤ 100). The next line contains n space separated integers forming the set. Each of these integers will line in the range [1, 109].
Output
For each case, print the case number and the multiple free subset as stated above.
Sample
Sample Input | Sample Output |
---|---|
6 3 2 2 4 4 2 4 6 10 6 7 1 2 2 5 9 4 3 10 10 5 5 7 2 9 9 49 10 1 2 3 4 5 6 7 8 9 10 | Case 1: 2 Case 2: 4 6 10 Case 3: 2 5 7 9 Case 4: 3 5 Case 5: 2 7 9 Case 6: 4 5 6 7 9 |