#include <bits/stdc++.h>
using namespace std;
const int MaxD = 7000, MaxN = 1001, logK = 40;
long long int dpsum[MaxD][MaxN], dpm[MaxD][MaxN], past[MaxD][MaxN], A[MaxN],
    pr[logK], pot[logK][logK];
int Div, divcan[MaxD][logK], Acan[MaxN][logK], cnt[logK], szdiv;
vector<long long int> Dv;
void dodiv(int pos, long long int w) {
  if (pos == szdiv) {
    Dv.push_back(w);
    return;
  }
  for (int j = 0; j <= cnt[pos]; j++) {
    dodiv(pos + 1, w);
    w *= pr[pos];
  }
}
unordered_map<long long int, int> hashi;
int main() {
  cin.tie(0), ios_base::sync_with_stdio(0);
  long long int i, j, p, r, q, N, K, k;
  cin >> N >> K;
  for (i = 2, p = 0, k = K; i * i <= k; i++) {
    if (k % i == 0) {
      pr[p] = i;
      while (k % i == 0) k /= i, cnt[p]++;
      p++;
    }
  }
  if (k > 1) pr[p] = k, cnt[p++] = 1;
  szdiv = p;
  for (j = 0; j < szdiv; j++) pot[j][0] = 1;
  for (j = 0; j < szdiv; j++)
    for (p = 1; p <= cnt[j]; p++) pot[j][p] = pot[j][p - 1] * pr[j];
  dodiv(0, 1);
  sort(Dv.begin(), Dv.end());
  Div = Dv.size();
  for (i = 0; i < Div; i++) {
    hashi[Dv[i]] = i;
    for (j = 0, p = Dv[i]; j < szdiv; j++)
      while (p % pr[j] == 0) divcan[i][j]++, p /= pr[j];
  }
  for (i = 1, p = 0, q = 10000000000000, r = 0; i <= N; i++) {
    cin >> A[i];
    if (A[i] % K == 0 && q > A[i]) q = A[i], p = 1, r = i;
  }
  if (p) {
    cout << p << "\n" << r;
    return 0;
  }
  for (i = 1; i <= N; i++) {
    for (j = 0, p = A[i]; j < szdiv; j++)
      while (p % pr[j] == 0) Acan[i][j]++, p /= pr[j];
  }
  for (i = 0; i < Div; i++) past[i][0] = dpsum[i][0] = dpm[i][0] = 10000;
  past[0][0] = dpm[0][0] = dpsum[0][0] = 0;
  for (i = 1; i <= N; i++) {
    for (j = 0; j < Div; j++) {
      dpm[j][i] = dpm[j][i - 1];
      dpsum[j][i] = dpsum[j][i - 1];
      past[j][i] = max(past[j][i - 1], j);
    }
    for (j = 0; j < Div; j++) {
      if (past[j][i - 1] >= 0) {
        for (p = 0, q = 1; p < szdiv; p++) {
          r = min(cnt[p], Acan[i][p] + divcan[j][p]);
          q = q * pot[p][r];
        }
        r = hashi[q];
        if (dpm[r][i] == dpm[j][i - 1] + 1 &&
            dpsum[r][i] > dpsum[j][i - 1] + A[i]) {
          past[r][i] = j;
          dpsum[r][i] = dpsum[j][i - 1] + A[i];
        }
        if (dpm[r][i] > dpm[j][i - 1] + 1) {
          dpm[r][i] = dpm[j][i - 1] + 1;
          dpsum[r][i] = dpsum[j][i - 1] + A[i];
          past[r][i] = j;
        }
      }
    }
  }
  if (past[Div - 1][N] <= Div - 1)
    cout << dpm[Div - 1][N] << "\n";
  else {
    cout << -1;
    return 0;
  }
  for (p = Div - 1, j = N; j > 0; j--) {
    if (p != past[p][j]) cout << j << " ";
    p = past[p][j];
  }
}
