#include <bits/stdc++.h>
using namespace std;
const long long UNDEF = -1;
template <typename T>
inline bool chkmax(T &a, T b) {
  return a < b ? a = b, true : false;
}
template <typename T>
inline bool chkmin(T &a, T b) {
  return a > b ? a = b, true : false;
}
const long long INF = 3e18;
const long long MAXL = 8000 + 4;
const long long MAXN = 1000 + 4;
long long a[MAXN];
pair<long long, long long> g[MAXN][MAXL];
int h[MAXN][MAXL];
vector<long long> dv;
long long dvsz;
long long trans[MAXN][MAXL];
long long getdi(long long x) {
  long long imin = 0, imax = dvsz;
  while (imin < imax) {
    long long imid = (imin + imax) / 2;
    if (dv[imid] < x)
      imin = imid + 1;
    else
      imax = imid;
  }
  return imin;
}
long long hasd[MAXL];
int main() {
  long long n, k;
  scanf("%I64d %I64d", &n, &k);
  for (long long i = 0; i < n; i++) {
    scanf("%I64d", &a[i]);
  }
  if (k == 1) {
    pair<long long, long long> ans = make_pair(a[0], 0LL);
    for (long long i = 1; i < n; i++) {
      chkmin(ans, make_pair(a[i], i));
    }
    printf("1\n%I64d\n", ans.second + 1);
    return 0;
  }
  set<long long> s;
  long long dlim = sqrt(k) + 1;
  for (long long d = 1; d <= dlim; d++) {
    if (0 == k % d) {
      s.insert(d);
      s.insert(k / d);
    }
  }
  for (auto &w : s) {
    dv.push_back(w);
  }
  dvsz = dv.size();
  for (long long x = 1; x < dvsz; x++) hasd[x] = UNDEF;
  vector<long long> pv;
  for (long long x = 1; x < dvsz; x++) {
    if (hasd[x] != UNDEF) continue;
    pv.push_back(x);
    long long v = dv[x];
    for (long long y = x + 1; y < dvsz; y++) {
      if (hasd[y] != UNDEF) continue;
      long long w = dv[y];
      if (w % v == 0) {
        hasd[y] = x;
      }
    }
  }
  long long pvsz = pv.size();
  for (long long x = 0; x < n; x++) {
    for (long long l = 0; l < dvsz; l++) {
      trans[x][l] = 1;
    }
  }
  for (long long l = 1; l < dvsz; l++) {
    long long hd = hasd[l];
    if (hd == UNDEF) hd = l;
    long long p = dv[hd];
    long long tmpl = dv[l];
    long long r = getdi(tmpl / p);
    long long pe = 1;
    while (tmpl % p == 0) {
      tmpl /= p;
      pe *= p;
    }
    for (long long x = 0; x < n; x++) {
      long long got = trans[x][r];
      if (a[x] % pe == 0) {
        trans[x][l] = got * p;
      } else {
        trans[x][l] = got;
      }
    }
  }
  for (long long x = 0; x < n; x++)
    for (long long l = 0; l < dvsz; l++) {
      trans[x][l] = getdi(dv[l] / trans[x][l]);
    }
  for (long long y = 0; y < dvsz; y++) g[n][y] = make_pair(INF, INF);
  g[n][0] = make_pair(0LL, 0LL);
  for (long long x = n - 1; x >= 0; x--)
    for (long long y = 0; y < dvsz; y++) {
      pair<long long, long long> av = g[x + 1][y];
      long long ny = trans[x][y];
      pair<long long, long long> bv = g[x + 1][ny];
      bv.first++;
      bv.second += a[x];
      if (av < bv) {
        g[x][y] = av;
        h[x][y] = y;
      } else {
        g[x][y] = bv;
        h[x][y] = ny;
      }
    }
  vector<long long> ans;
  {
    long long x = 0, y = dvsz - 1;
    if (g[x][y].first == INF) {
      printf("-1\n");
      return 0;
    }
    while (1) {
      if (x == n && y == 0) break;
      long long ny = h[x][y];
      if (ny != y) {
        ans.push_back(x);
      }
      y = ny;
      x++;
    }
  }
  long long asz = ans.size();
  printf("%I64d\n", asz);
  for (auto &w : ans) {
    printf("%I64d ", w + 1);
  }
  printf("\n");
}
