Permutations
Given set of n different positive integers. Permutation of the elements of this set is called ak-permutation, if for any two adjacent elements of the permutation of their greatest common factor of not less than k. For example, if a given set of elements S = {6, 3, 9, 8}, the permutation of {8, 6, 3, 9} is a 2-permutation, a permutation of {6, 8, 3, 9} – no.
Rearrange {p_1, p_2, …, p_n} is lexicographically smaller permutation of {q_1, q_2, …, q_n}, if there exists an integer i (1 ≤ i ≤ n), for which p_j = q_j for j < i and p_i < q_i.
As an example, order all the k-permutation of a given above sets in lexicographical order. For example, there are exactly four 2-permutation of the set S: {3, 9, 6, 8}, {8, 6, 3, 9}, {8, 6, 9, 3} and {9, 3, 6, 8}. Accordingly, the first 2-permutation in lexicographical order is the set {3, 9, 6, 8}, and the fourth - the set {9, 3, 6, 8}.
Need to write a program that allows to find the m-th k-permutation in that order.
Input
The first line contains three natural numbers n (1 ≤ n ≤ 16), m and k (1 ≤ m, k ≤ 10^9). The second line contains n distinct positive integers not exceeding 10^9. All numbers in rows are separated by a space.
Output
Print m-th k-permutation of a given set, or -1 if no such.