#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <queue>

using namespace std;

typedef long long ll;

#define pb push_back
#define sz(a) (int)a.size()
#define zero(a) memset (a, 0, sizeof(a))
#define mp make_pair

#define taskname "gcd"

const int maxn = 1000;

int a[maxn];
int n, d;

vector <int> ans;

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

int main (void)
{
  assert(freopen (taskname".in", "r", stdin));
  freopen (taskname".out", "w", stdout);

  assert(scanf ("%d%d", &n, &d) == 2);

  assert (1 <= n && n <= 1000 && 1 <= d && d <= 1000000000);

  for (int i = 0; i < n; i++)
  {
    assert (scanf("%d", &a[i]) == 1);
    assert (1 <= a[i] && a[i] <= 1000000000);

    if (a[i] % d == 0)
      ans.pb(a[i]);
  }

  int curgcd = 0;

  for (int i = 0; i < sz(ans); i++)
  {
    if (i == 0)
      curgcd = ans[i];
    curgcd = gcd(curgcd, ans[i]);
  }

  if (curgcd == 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;
}

