#include <bits/stdc++.h>
using namespace std;
const long long N = 100005;
const long long mod = 1000000007;
long long bp(long long x, long long y) {
  long long ans = 1;
  x %= mod;
  while (y) {
    if (y & 1) ans = ans * x % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long mod_inverse(long long x) { return bp(x, mod - 2); }
long long gcd(long long a, long long b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
long long max(long long a, long long b) {
  if (a < b) swap(a, b);
  return a;
}
long long min(long long a, long long b) {
  if (a > b) swap(a, b);
  return a;
}
long long countSetBits(long long n) {
  long long count = 0;
  while (n) {
    count += n & 1;
    n >>= 1;
  }
  return count;
}
pair<long long, long long> dp[1010][10010];
long long fact[10010], cnt = 0;
void solve() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, k;
  cin >> n >> k;
  long long a[n + 1], b[n + 1], rem = k, mn = 1e18 + 1e9, mn_idx;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    b[i] = gcd(a[i], k);
    rem /= gcd(rem, a[i]);
    if (mn > a[i]) mn = a[i], mn_idx = i;
  }
  if (rem > 1) {
    cout << "-1";
    return;
  }
  if (k == 1) {
    cout << "1" << '\n' << mn_idx;
    return;
  }
  for (long long i = 1; i * i <= k; i++) {
    if (k % i) continue;
    fact[cnt++] = i;
    if (i != k / i) fact[cnt++] = k / i;
  }
  sort(fact, fact + cnt);
  map<long long, long long> mp;
  for (long long i = 0; i < cnt; i++) mp[fact[i]] = i;
  for (long long i = 1; i < cnt; i++) dp[0][i] = {n + 1, 0};
  dp[0][0] = {0, 0};
  for (long long i = 1; i <= n; i++) {
    for (long long j = 0; j < cnt; j++) {
      dp[i][j] = dp[i - 1][j];
      long long t = mp[fact[j] / gcd(fact[j], b[i])];
      if (dp[i][j] >
          make_pair(dp[i - 1][t].first + 1, dp[i - 1][t].second + a[i]))
        dp[i][j] = {dp[i - 1][t].first + 1, dp[i - 1][t].second + a[i]};
    }
  }
  cout << dp[n][cnt - 1].first << '\n';
  rem = k;
  for (long long i = n; i > 0; i--) {
    if (dp[i][mp[rem]] == dp[i - 1][mp[rem]]) continue;
    cout << i << " ";
    rem /= gcd(rem, b[i]);
  }
}
signed main() { solve(); }
