#include <bits/stdc++.h>
using namespace std;
int n;
long long k;
long long a[1000 + 5];
pair<long long, int> divizori[7000 + 5];
long long factorizare[7000 + 5][45];
int nr_divizori;
int sol[1000 + 5][7000 + 5];
long long sum[1000 + 5][7000 + 5];
int prec[1000 + 5][7000 + 5][2];
int loc[1000 + 5][7000 + 5];
long long factori[7000 + 5];
int nr_factori;
int exponenti[7000 + 5];
long long gcd[1000 + 5][45];
void genereaza_divizori(int unde, long long val) {
  if (unde == 0) {
    ++nr_divizori;
    divizori[nr_divizori].first = val;
    divizori[nr_divizori].second = nr_divizori;
    for (int i = 1; i <= nr_factori; ++i) {
      factorizare[nr_divizori + 1][i] = factorizare[nr_divizori][i];
    }
  } else {
    long long val2 = 1;
    for (int i = 0; i <= exponenti[unde]; ++i) {
      factorizare[nr_divizori + 1][unde] = val2;
      genereaza_divizori(unde - 1, val * val2);
      val2 *= factori[unde];
    }
  }
}
int main() {
  scanf("%d %I64d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%I64d", &a[i]);
  }
  long long val = k;
  long long factor = 2;
  while (val > 1 && 1LL * factor * factor <= k) {
    if (val % factor == 0) {
      ++nr_factori;
      factori[nr_factori] = factor;
      while (val % factor == 0) {
        exponenti[nr_factori]++;
        val /= factor;
      }
    }
    factor++;
  }
  if (val > 1) {
    ++nr_factori;
    factori[nr_factori] = val;
    exponenti[nr_factori] = 1;
  }
  genereaza_divizori(nr_factori, 1);
  sort(divizori + 1, divizori + 1 + nr_divizori);
  for (int i = 1; i <= n; ++i) {
    long long v1 = k;
    long long v2 = a[i];
    for (int j = 1; j <= nr_factori; ++j) {
      gcd[i][j] = 1;
      while (v1 % factori[j] == 0 && v2 % factori[j] == 0) {
        gcd[i][j] *= factori[j];
        v1 /= factori[j];
        v2 /= factori[j];
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= nr_divizori; ++j) {
      long long v1 = divizori[j].first;
      long long v2;
      long long cmmdc = 1;
      int pz = divizori[j].second;
      for (int k = 1; k <= nr_factori; ++k) {
        if (factorizare[pz][k] < gcd[i][k]) {
          cmmdc *= factorizare[pz][k];
        } else {
          cmmdc *= gcd[i][k];
        }
      }
      v2 = divizori[j].first / cmmdc;
      int st = 1;
      int dr = nr_divizori;
      while (st != dr) {
        int m = (st + dr) / 2;
        if (divizori[m].first >= v2) {
          dr = m;
        } else {
          st = m + 1;
        }
      }
      loc[i][j] = st;
    }
  }
  for (int i = 0; i <= nr_divizori; ++i) {
    sol[0][i] = 1000000;
  }
  sol[0][1] = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= nr_divizori; ++j) {
      sol[i][j] = sol[i - 1][j];
      sum[i][j] = sum[i - 1][j];
      prec[i][j][0] = prec[i - 1][j][0];
      prec[i][j][1] = prec[i - 1][j][1];
      if (a[i] % divizori[j].first == 0) {
        if (sol[i][j] > 1) {
          sol[i][j] = 1;
          sum[i][j] = a[i];
          prec[i][j][0] = i;
          prec[i][j][1] = j;
        } else if (sol[i][j] == 1 && (a[i] < sum[i][j])) {
          sol[i][j] = 1;
          sum[i][j] = a[i];
          prec[i][j][0] = i;
          prec[i][j][1] = j;
        }
      }
      int h = loc[i][j];
      if ((sol[i][j] == 0) || (sol[i][j] > sol[i - 1][h] + 1)) {
        sol[i][j] = sol[i - 1][h] + 1;
        sum[i][j] = sum[i - 1][h] + a[i];
        prec[i][j][0] = i;
        prec[i][j][1] = j;
      } else if ((sol[i][j] == (sol[i - 1][h] + 1)) &&
                 (sum[i][j] > (sum[i - 1][h] + a[i]))) {
        sum[i][j] = sum[i - 1][h] + a[i];
        prec[i][j][0] = i;
        prec[i][j][1] = j;
      }
    }
  }
  if (sol[n][nr_divizori] < 1000000) {
    printf("%d\n", sol[n][nr_divizori]);
    int i = n;
    int j = nr_divizori;
    int ti = i;
    int tj = j;
    i = prec[ti][tj][0];
    j = prec[ti][tj][1];
    while (sol[n][nr_divizori] > 0) {
      printf("%d ", i);
      ti = i;
      tj = j;
      i = prec[ti - 1][loc[ti][tj]][0];
      j = prec[ti - 1][loc[ti][tj]][1];
      sol[n][nr_divizori]--;
    }
  } else {
    printf("-1");
  }
  return 0;
}
