#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
const long long INF = 1e9 + 5;
long long k, A[maxn];
int n, count_primes = 0, count_divs = 1;
pair<int, long long> dp[maxn][7000];
pair<long long, int> PrimesK[maxn];
int PrimesA[maxn][7000], p[maxn][7000];
long long Mul[maxn];
void Prepare(long long k) {
  for (int i = 2; 1ll * i * i <= k; ++i)
    if (k % i == 0) {
      PrimesK[++count_primes] = pair<long long, int>(i, 0);
      while (k % i == 0) {
        PrimesK[count_primes].second++;
        k /= i;
      }
    }
  if (k != 1) PrimesK[++count_primes] = pair<long long, int>(k, 1);
  for (int i = 1; i <= n; ++i) {
    long long x = A[i];
    for (int j = 1; j <= count_primes; ++j)
      if (x % PrimesK[j].first == 0) {
        while (x % PrimesK[j].first == 0) {
          PrimesA[i][j]++;
          x /= PrimesK[j].first;
        }
      }
  }
  for (int i = 1; i <= count_primes; ++i) count_divs *= (PrimesK[i].second + 1);
  Mul[count_primes] = 1;
  for (int i = count_primes - 1; i >= 1; --i)
    Mul[i] = Mul[i + 1] * (PrimesK[i + 1].second + 1);
}
int main() {
  scanf("%d%I64d", &n, &k);
  for (int i = 1; i <= n; ++i) scanf("%I64d", &A[i]);
  if (k == 1) {
    pair<long long, int> ans = pair<long long, int>(1e18, -1);
    for (int i = 1; i <= n; ++i) ans = min(ans, pair<long long, int>(A[i], i));
    puts("1");
    printf("%d", ans.second);
    return 0;
  }
  Prepare(k);
  for (int i = 0; i <= count_divs; ++i) dp[0][i] = pair<int, long long>(INF, 0);
  dp[0][0] = pair<int, long long>(0, 0);
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < count_divs; ++j) {
      dp[i][j] = pair<int, long long>(INF, 0);
      int cnt = 0;
      int cur = j;
      for (int q = 1; q <= count_primes; ++q) {
        cnt += Mul[q] * max(0, (int)(cur / Mul[q] - PrimesA[i][q]));
        cur %= Mul[q];
      }
      if (dp[i - 1][cnt].first + 1 < dp[i][j].first) {
        dp[i][j] = pair<int, long long>(dp[i - 1][cnt].first + 1,
                                        dp[i - 1][cnt].second + A[i]);
        p[i][j] = cnt;
      }
      if (dp[i - 1][cnt].first + 1 == dp[i][j].first &&
          dp[i - 1][cnt].second + A[i] < dp[i][j].second) {
        dp[i][j] = pair<int, long long>(dp[i - 1][cnt].first + 1,
                                        dp[i - 1][cnt].second + A[i]);
        p[i][j] = cnt;
      }
      if (dp[i - 1][j] < dp[i][j]) {
        dp[i][j] = dp[i - 1][j];
        p[i][j] = j;
      }
    }
  }
  if (dp[n][count_divs - 1].first >= INF) {
    puts("-1");
    return 0;
  }
  printf("%d\n", dp[n][count_divs - 1].first);
  for (int i = n, j = count_divs - 1; j > 0; j = p[i--][j])
    if (p[i][j] < j) printf("%d ", i);
  return 0;
}
