#include <bits/stdc++.h>
using namespace std;
template <typename T>
void chmin(T &x, const T &y) {
  if (x > y) x = y;
}
template <typename T>
void chmax(T &x, const T &y) {
  if (x < y) x = y;
}
int read() {
  char c;
  while ((c = getchar()) < '-')
    ;
  if (c == '-') {
    int x = (c = getchar()) - '0';
    while ((c = getchar()) >= '0') x = x * 10 + c - '0';
    return -x;
  }
  int x = c - '0';
  while ((c = getchar()) >= '0') x = x * 10 + c - '0';
  return x;
}
const int N = 1000 + 5, T = 6800;
int n;
long long a[N];
long long k;
long long pr[30];
int cnt[30], w[30], tot;
int dp1[N][T];
long long dp2[N][T];
int *f0, *f1;
long long *g0, *g1;
void fen(long long k) {
  int g = sqrt(k);
  for (int i = 2; i <= g; ++i)
    if (k % i == 0) {
      pr[tot] = i;
      while (k % i == 0) {
        k /= i;
        ++cnt[tot];
      }
      ++tot;
    }
  if (k > 1) {
    pr[tot] = k;
    cnt[tot] = 1;
    ++tot;
  }
  w[tot] = 1;
  for (int i = tot - 1, i_l = 0; i >= i_l; --i)
    w[i] = w[i + 1] * (cnt[i + 1] + 1);
}
int ncnt[30];
long long nx;
void get(long long x) {
  nx = x;
  for (int i = 0, i_r = tot - 1; i <= i_r; ++i) {
    int j = 0;
    while (x % pr[i] == 0) {
      ++j;
      x /= pr[i];
    }
    ncnt[i] = min(cnt[i], j);
  }
}
void dfs(int nw, int ni, int tw) {
  if (ni >= tot) {
    if (f0[nw] < f0[tw] + 1 ||
        (f0[nw] == f0[tw] + 1 && g0[nw] <= g0[tw] + nx)) {
      f1[nw] = f0[nw];
      g1[nw] = g0[nw];
    } else {
      f1[nw] = f0[tw] + 1;
      g1[nw] = g0[tw] + nx;
    }
    return;
  }
  int j = 0;
  for (; j <= ncnt[ni]; ++j) {
    dfs(nw, ni + 1, tw);
    nw += w[ni];
  }
  for (; j <= cnt[ni]; ++j) {
    tw += w[ni];
    dfs(nw, ni + 1, tw);
    nw += w[ni];
  }
}
int main() {
  cin >> n >> k;
  for (int i = 1, i_r = n; i <= i_r; ++i) scanf("%lld", &a[i]);
  if (k == 1) {
    puts("1");
    long long mn = a[1];
    int mni = 1;
    for (int i = 2, i_r = n; i <= i_r; ++i)
      if (a[i] < mn) {
        mn = a[i];
        mni = i;
      }
    printf("%d\n", mni);
    return 0;
  }
  fen(k);
  int TT = (cnt[0] + 1) * w[0] - 1;
  for (int i = 1, i_r = TT; i <= i_r; ++i) dp1[0][i] = N;
  for (int i = 1, i_r = n; i <= i_r; ++i) {
    f1 = dp1[i];
    g1 = dp2[i];
    f0 = dp1[i - 1];
    g0 = dp2[i - 1];
    get(a[i]);
    dfs(0, 0, 0);
  }
  if (dp1[n][TT] == N)
    puts("-1");
  else {
    printf("%d\n", dp1[n][TT]);
    vector<int> ans;
    int nw = TT;
    for (int i = n, i_l = 1; i >= i_l; --i) {
      get(a[i]);
      int tw = 0;
      for (int i = 0, i_r = tot - 1; i <= i_r; ++i)
        tw += (cnt[i] - ncnt[i]) * w[i];
      if (dp1[i][nw] == dp1[i - 1][tw] + 1 &&
          dp2[i][nw] == dp2[i - 1][tw] + nx) {
        ans.push_back(i);
        nw = tw;
        for (int i = 0, i_r = tot - 1; i <= i_r; ++i) cnt[i] -= ncnt[i];
      }
    }
    for (auto x : ans) printf("%d ", x);
  }
}
