#include <cstdio>
#include <vector>

int gcd(int a, int b)
{
    int c;
    while (b)
    {
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}

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

    int n, d;
    scanf("%d%d", &n, &d);
    std::vector <int> v;
    int curGcd = 0;
    for (int i = 0; i < n; ++i)
    {
        int a;
        scanf("%d", &a);
        if (a % d == 0 && a % curGcd != 0)
        {
            curGcd = gcd(curGcd, a);
            v.push_back(a);
        }
    }
    if (curGcd == d)
    {
        printf("%d\n", int(v.size()));
        for (int i = 0; i < int(v.size()); ++i)
            printf("%d ", v[i]);
        printf("\n");
    }
    else
        printf("-1\n");

    return 0;
}