CF2173C Kanade's Perfect Multiples

Description

We've carved those memories into ourselves... No matter how hard they were, they're the lives we carried out! — Angel Beats! In the afterlife school, Kanade studies a peculiar number game. She gives you two integers $ n $ and $ k $ , as well as an array $ a $ consisting of $ n $ integers, where $ 1 \le a_i \le k $ holds. For an integer set $ B = \{b_1, b_2, \ldots, b_m\} $ where $ 1\le b_i\le k $ , we call it complete if and only if both of the following hold: - For each $ 1\le i\le n $ , at least one divisor of $ a_i $ is contained in $ B $ ; - For each $ 1\le j\le m $ , all positive multiples of $ b_j $ which are less than or equal to $ k $ appear in the array $ a $ at least once. You have to find a complete set $ B $ with minimum possible size, or determine that no such set exists.

Input Format

Each test contains multiple test cases. The first line contains the number of test cases $ t $ ( $ 1 \le t \le 10^4 $ ). The description of the test cases follows. The first line of each test case contains two integers $ n $ and $ k $ ( $ 1\le n\le 2\cdot 10^5 $ , $ 1\le k\le 10^9 $ ) — the length of $ a $ and the upper bound of elements of $ a $ . The second line contains $ n $ integers $ a_1, a_2, \ldots, a_n $ ( $ 1\le a_i\le k $ ) — the elements of $ a $ . It is guaranteed that the sum of $ n $ over all test cases does not exceed $ 2\cdot 10^5 $ .

Output Format

For each test case: - If no complete set $ B $ exists, print a single integer $ -1 $ in the only line of output. - Otherwise: - First print a single integer $ m $ ( $ 1\le m\le n $ ) in the first line of output — the size of $ B $ . Note that you have to minimize the size of $ B $ . - Then output $ m $ integers $ b_1, b_2, \ldots, b_m $ ( $ 1 \le b_i \le k $ ) in the second line — the set you constructed. If there are multiple answers, you may print any of them.

Explanation/Hint

In the first test case, $ B=\{2,3\} $ works. For $ b=2 $ , all multiples $ \{2,4,6\} $ (up to $ k=6 $ ) appear in $ a $ ; for $ b=3 $ , multiples $ \{3,6\} $ appear. Every $ a_i $ is divisible by $ 2 $ or $ 3 $ . No single $ b $ can satisfy both conditions, so $ m=2 $ is minimal. In the second test case, $ B=\{1\} $ satisfies both rules since every number is divisible by $ 1 $ and all multiples of $ 1 $ up to $ k $ appear.