#include <bits/stdc++.h>
using namespace std;
long long a[123456], k;
pair<long long, int> snt[123456];
int mul[123456], slg_div, q[1002][7002], prime, n, par[1002][7002];
pair<int, long long> dp[1002][7002];
void pre() {
  long long hihi = k;
  for (int i = 2; i * i <= hihi; i++) {
    if (hihi % i) continue;
    snt[++prime] = make_pair(i, 0);
    while ((hihi % i) == 0) {
      hihi /= i;
      snt[prime].second++;
    }
  }
  if (hihi > 1) snt[++prime] = make_pair(hihi, 1);
  for (int i = 1; i <= n; i++) {
    hihi = a[i];
    for (int j = 1; j <= prime; j++) {
      while (hihi % snt[j].first == 0) {
        q[i][j]++;
        hihi /= snt[j].first;
      }
    }
  }
  slg_div = 1;
  for (int i = 1; i <= prime; i++) slg_div *= (snt[i].second + 1);
  mul[prime] = 1;
  for (int i = prime - 1; i >= 1; i--)
    mul[i] = mul[i + 1] * (snt[i + 1].second + 1);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  if (k == 1) {
    int ans = 1;
    for (int i = 2; i <= n; i++)
      if (a[i] < a[ans]) ans = i;
    cout << 1 << endl;
    cout << ans;
    return 0;
  }
  pre();
  for (int j = 1; j <= slg_div; j++) dp[0][j] = make_pair(1000000007, 0);
  dp[0][1] = make_pair(0, 0);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= slg_div; j++) {
      dp[i][j] = make_pair(1000000007, 0);
      int cur = j - 1, last = 0;
      for (int t = 1; t <= prime; t++) {
        last += mul[t] * max(0, cur / mul[t] - q[i][t]);
        cur %= mul[t];
      }
      last++;
      if (dp[i - 1][last].first + 1 < dp[i][j].first) {
        dp[i][j].first = dp[i - 1][last].first + 1;
        dp[i][j].second = dp[i - 1][last].second + a[i];
        par[i][j] = last;
      }
      if (dp[i - 1][last].first + 1 == dp[i][j].first &&
          dp[i - 1][last].second + a[i] < dp[i][j].second) {
        dp[i][j].second = dp[i - 1][last].second + a[i];
        par[i][j] = last;
      }
      if (dp[i - 1][j] < dp[i][j]) {
        dp[i][j] = dp[i - 1][j];
        par[i][j] = j;
      }
    }
  }
  if (dp[n][slg_div].first == 1000000007) {
    cout << -1;
    return 0;
  }
  cout << dp[n][slg_div].first << endl;
  int luu = slg_div;
  for (int i = n; i >= 1; i--) {
    if (par[i][luu] == luu) continue;
    cout << i << " ";
    luu = par[i][luu];
  }
  return 0;
}
