#include <bits/stdc++.h>
int N, D, cnt[10], e[1001], p[1001][10], L = 1;
long long K, pr[10], a[1001];
std::pair<int, long long> f[1001][6720];
int ch[1001][6720];
void Fenka(long long t) {
  for (long long i = 2; i * i <= t; i++)
    if (t % i == 0) {
      pr[D] = i;
      do cnt[D]++, t /= i;
      while (t % i == 0);
      D++;
    }
  if (t > 1) {
    pr[D] = t;
    cnt[D++] = 1;
  }
}
void dfs(int i, int k, int x, int y) {
  if (k == -1) {
    std::pair<int, long long> TRY = {f[i - 1][y].first + 1,
                                     f[i - 1][y].second + a[i]};
    if (TRY < f[i][x]) {
      f[i][x] = TRY;
      ch[i][x] = y;
    }
    return;
  }
  for (int u = 0; u <= cnt[k]; u++)
    dfs(i, k - 1, x * (cnt[k] + 1) + u,
        y * (cnt[k] + 1) + std::max(0, u - p[i][k]));
}
int main() {
  scanf("%d%lld", &N, &K);
  Fenka(K);
  for (int i = 0; i < D; i++) L *= cnt[i] + 1;
  for (int i = 1; i < L; i++) f[0][i] = {N + 1, 1000000000001LL * N};
  for (int i = 1; i <= N; i++) {
    scanf("%lld", a + i);
    long long t = a[i];
    for (int j = 0; j < D; j++)
      while (p[i][j] < cnt[j] && t % pr[j] == 0) {
        p[i][j]++;
        t /= pr[j];
      }
    for (int j = 0; j < L; j++) {
      f[i][j] = f[i - 1][j];
      ch[i][j] = j;
    }
    dfs(i, D - 1, 0, 0);
  }
  if (f[N][L - 1].first > N) {
    puts("-1");
    return 0;
  }
  if (f[N][L - 1].first == 0) {
    int z = 1;
    for (int i = 2; i <= N; i++)
      if (a[i] < a[z]) z = i;
    printf("1\n%d\n", z);
    return 0;
  }
  printf("%d\n", f[N][L - 1].first);
  for (int i = N, j = L - 1; i; i--)
    if (ch[i][j] != j) {
      printf("%d ", i);
      j = ch[i][j];
    }
  puts("");
  return 0;
}
