#include <cstdio>
#include <vector>
using namespace std;
#define pb push_back
#define sz(a) ((int) (a).size())

int gcd(int a, int b) {
	return b ? gcd(b, a % b) : a;
}

int main() {
	freopen("gcd.in", "r", stdin);
	freopen("gcd.out", "w", stdout);
	int n, d, g = 0, x;
	vector<int> ans;
	scanf("%d%d", &n, &d);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &x);
		if (x % d == 0) {
			ans.pb(x);
			g = gcd(g, x);
		}
	}
	if (g == d) {
		printf("%d\n", sz(ans));
		for (int i = 0; i < sz(ans); ++i)
			printf("%d ", ans[i]);
		printf("\n");
	} else 
		printf("-1\n");
	return 0;
}
