#include
using namespace std;
typedef long long dint; #define _l (long long int) #ifdef WIN32
define lld “%I64d”
#else
define lld “%lld”
#endif
const int maxs = (1 « 22) + 1; const int maxf = 23; const int inf = 0x3f3f3f3f; const int maxn = 1003;
typedef pair <dint, int> item;
item a[maxn]; dint k, kf[maxf], fs[maxs]; int f[maxs], ff[maxs], cs[maxs], fv[maxs], n, m, t, cf[maxf], v[maxf], vn[maxf], c;
void dissolve(dint k) { t = 0; m = 1; for (dint i = 2; i * i <= k; ++ i) { if (k % i == 0) { kf[t] = i; for (cf[t] = 0; k % i == 0; k /= i, ++ cf[t]); ++ t; } } if (k > 1) { kf[t] = k; cf[t] = 1; ++ t; } for (int i = 0; i < t; ++ i) { m *= cf[i] + 1; } }
void unzipState(int* a, int s) { for (int i = 0; i < t; ++ i) { a[i] = s % (cf[i] + 1); s /= cf[i] + 1; } } int zipState(int* a) { int s(0); for (int i = t - 1; i >= 0; – i) { s = s * (cf[i] + 1) + a[i]; } return s; }
int main() { #ifdef LAEKOV_LOCAL freopen(".in", “r”, stdin); #endif
scanf("%d" lld, &n, &k);
dissolve(k);
memset(f, 0x3f, sizeof(f));
memset(fs, 0x3f, sizeof(fs));
f[0] = fs[0] = 0;
for (int i = 0; i < n; ++ i) {
scanf(lld, &a[i].first);
a[i].second = i + 1;
}
sort(a, a + n);
c = 0;
cs[0] = 0;
for (int ti = 0; ti < n; ++ ti) {
dint z(a[ti].first);
for (int i = 0; i < t; ++ i) {
for (vn[i] = 0; z % kf[i] == 0; z /= kf[i], ++ vn[i]);
}
for (int j = m - 1; j >= 0; -- j) {
if (f[j] < inf) {
unzipState(v, j);
for (int k = 0; k < t; ++ k) {
v[k] = min(cf[k], v[k] + vn[k]);
}
int sn(zipState(v));
if (f[j] + 1 < f[sn] || (f[j] + 1 == f[sn] && fs[j] + a[ti].first < fs[sn])) {
f[sn] = f[j] + 1;
fs[sn] = fs[j] + a[ti].first;
fv[cs[sn] = ++ c] = a[ti].second;
ff[c] = cs[j];
}
}
}
}
if (!t) {
printf("1\n%d\n", a[0].second);
} else if (f[m - 1] > n) {
puts("-1");
} else {
printf("%d\n", f[m - 1]);
for (int i = cs[m - 1]; i; i = ff[i]) {
printf("%d%c", fv[i], ff[i] ? 32 : 10);
}
}
}