import java.io.*;
import java.util.*;

public class gcd_va implements Runnable {
	public static void main(String[] args) {
		new Thread(new gcd_va()).run();
	}

	BufferedReader br;
	StringTokenizer in;
	PrintWriter out;

	public String nextToken() throws IOException {
		while (in == null || !in.hasMoreTokens()) {
			in = new StringTokenizer(br.readLine());
		}

		return in.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public int gcd(int a, int b) {
		if (b == 0)
			return a;
		else
			return gcd(b, a % b);
	}

	public void solve() throws IOException {
		int n = nextInt();
		int d = nextInt();

		ArrayList<Integer> ans = new ArrayList<Integer>();

		int gcd = 0;
		for (int i = 0; i < n; i++) {
			int a = nextInt();
			if (a % d != 0)
				continue;

			ans.add(a);
			gcd = gcd(gcd, a);
		}

		if (gcd != d) {
			out.println(-1);
			return;
		}

		out.println(ans.size());

		for (int u : ans) {
			out.print(u + " ");
		}
	}

	public void run() {
		try {
			br = new BufferedReader(new FileReader("gcd.in"));
			out = new PrintWriter("gcd.out");

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}
}
