#include <bits/stdc++.h>
using namespace std;
void fre() {
  freopen("c://test//input.in", "r", stdin);
  freopen("c://test//output.out", "w", stdout);
}
template <class T1, class T2>
inline void gmax(T1 &a, T2 b) {
  if (b > a) a = b;
}
template <class T1, class T2>
inline void gmin(T1 &a, T2 b) {
  if (b < a) a = b;
}
const int N = 1010, M = 0, Z = 1e9 + 7, ms63 = 0x3f3f3f3f;
int n, m;
long long K;
long long a[N];
long long b[N];
vector<long long> v;
unordered_map<long long, int> mop;
pair<int, long long> f[N][N * 10];
long long gcd(long long x, long long y) { return y == 0 ? x : gcd(y, x % y); }
void init() {
  v.clear();
  int top = sqrt(K + 0.5);
  for (int i = 1; i <= top; ++i)
    if (K % i == 0) {
      v.push_back(i);
      if (K / i != i) v.push_back(K / i);
    }
  sort(v.begin(), v.end());
  m = v.size() - 1;
  mop.clear();
  for (int i = 0; i <= m; ++i) mop[v[i]] = i;
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", &a[i]);
    b[i] = gcd(a[i], K);
  }
}
void dp() {
  if (K == 1) {
    puts("1");
    printf("%lld\n", min_element(a + 1, a + n + 1) - a);
    return;
  }
  for (int j = 1; j <= m; ++j) f[0][j] = {n + 1, 0};
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= m; ++j) {
      f[i][j] = f[i - 1][j];
      int pre = mop[v[j] / gcd(v[j], b[i])];
      gmin(f[i][j],
           make_pair(f[i - 1][pre].first + 1, f[i - 1][pre].second + a[i]));
    }
  }
  if (f[n][m].first > n)
    puts("-1");
  else {
    printf("%d\n", f[n][m].first);
    for (int i = n; i; --i) {
      if (f[i][mop[K]] != f[i - 1][mop[K]]) {
        printf("%d ", i);
        K /= gcd(K, b[i]);
      }
    }
    puts("");
  }
}
int main() {
  while (~scanf("%d%lld", &n, &K)) {
    init();
    dp();
  }
  return 0;
}
