#include <bits/stdc++.h>
using namespace std;
int n;
long long k;
long long A[7006];
pair<int, long long> dp[1006][7006];
int small[1000006], big[1000006];
vector<long long> divs;
inline long long gcd(long long a, long long b) {
  return !b ? a : gcd(b, a % b);
}
inline int get(long long x) {
  if (x > k / x) return big[k / x];
  return small[x];
}
int a[7006];
void solve() {
  cin >> n >> k;
  for (int i = (1), iend = (n); i <= iend; ++i)
    scanf("%lld", A + i), a[i] = gcd(A[i], k);
  if (k == 1) {
    pair<long long, int> mn = make_pair(0x3f3f3f3f3f3f3f3f, 0);
    for (int i = (1), iend = (n); i <= iend; ++i)
      mn = min(mn, make_pair(A[i], i));
    printf("%d\n%lld\n", 1, mn.second);
    return;
  }
  for (long long i = 1; i * i <= k; ++i)
    if (k % i == 0) {
      divs.push_back(i), small[i] = divs.size() - 1;
      if (i * i != k) divs.push_back(k / i), big[i] = divs.size() - 1;
    }
  int sz = divs.size();
  for (int i = 0; i < sz; ++i) dp[0][i] = {n + 1, 0};
  dp[0][0] = make_pair(0, 0);
  long long gg;
  int idx;
  pair<int, long long> qw;
  for (int i = (1), iend = (n); i <= iend; ++i) {
    for (int j = (0), jend = (sz - 1); j <= jend; ++j) {
      idx = get(divs[j] / gcd(divs[j], a[i]));
      dp[i][j] =
          min(make_pair(dp[i - 1][idx].first + 1, dp[i - 1][idx].second + A[i]),
              dp[i - 1][j]);
    }
  }
  if (dp[n][1].first > n) return puts("-1"), void();
  cout << dp[n][1].first << endl;
  int c = 1;
  for (int i = n; i; --i) {
    if (dp[i][c] != dp[i - 1][c]) {
      printf("%d ", i), c = get(divs[c] / gcd(divs[c], a[i]));
    }
  }
}
signed main() { solve(); }
