#include <bits/stdc++.h>
using namespace std;
inline bool SR(int &x) { return scanf("%d", &x) == 1; }
inline bool SR(long long &x) { return scanf("%lld", &x) == 1; }
inline bool SR(double &x) { return scanf("%lf", &x) == 1; }
inline bool SR(char *s) { return scanf("%s", s) == 1; }
inline bool RI() { return true; }
template <typename I, typename... T>
inline bool RI(I &x, T &...tail) {
  return SR(x) && RI(tail...);
}
inline void SP(const int x) { printf("%d", x); }
inline void SP(const long long x) { printf("%lld", x); }
inline void SP(const double x) { printf("%.16lf", x); }
inline void SP(const char *s) { printf("%s", s); }
inline void PL() { puts(""); }
template <typename I, typename... T>
inline void PL(const I x, const T... tail) {
  SP(x);
  if (sizeof...(tail)) putchar(' ');
  PL(tail...);
}
template <typename I>
void _DOING(const char *s, I &&x) {
  cerr << s << " = " << x << endl;
}
template <typename I, typename... T>
void _DOING(const char *s, I &&x, T &&...tail) {
  int c = 0;
  while (*s != ',' || c != 0) {
    if (*s == '(' || *s == '[' || *s == '{') c++;
    if (*s == ')' || *s == ']' || *s == '}') c--;
    cerr << *s++;
  }
  cerr << " = " << x << " , ";
  _DOING(s + 1, tail...);
}
inline int RAND() {
  static int x = 880301;
  return (x = x * 0xdefaced + 1) & 0x7fffffff;
}
const int INF = 0x3f3f3f3f;
const int MAX_N = 1000 + 10;
long long a[MAX_N];
vector<long long> factor;
unordered_map<long long, int> table;
pair<int, long long> dp[MAX_N][10000];
pair<int, int> path[MAX_N][10000];
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
int main() {
  int n;
  long long k;
  RI(n, k);
  for (int i = 1; i <= int(n); i++) RI(a[i]);
  if (k == 1LL) {
    PL(1);
    int ans = 1;
    for (int i = 1; i <= int(n); i++) {
      if (a[ans] > a[i]) ans = i;
    }
    PL(ans);
  } else {
    for (long long i = 1; i * i <= k; i++) {
      if (k % i) continue;
      long long j = k / i;
      factor.push_back(i);
      if (j != i) factor.push_back(j);
    }
    sort((factor).begin(), (factor).end());
    for (int i = 0; i < int(((int)factor.size())); i++) table[factor[i]] = i;
    for (int i = 0; i <= int(n); i++) {
      for (int j = 0; j < int(((int)factor.size())); j++) {
        dp[i][j] = make_pair(INF, 0);
        path[i][j] = make_pair(0, 0);
      }
    }
    dp[0][0] = make_pair(0, 0);
    for (int i = 1; i <= int(n); i++) {
      if (gcd(k, a[i]) == 1) {
        for (int j = 0; j < int(((int)factor.size())); j++) {
          dp[i][j] = dp[i - 1][j];
          path[i][j] = make_pair(i - 1, j);
        }
        continue;
      }
      for (int j = 0; j < int(((int)factor.size())); j++) {
        if (dp[i][j] > dp[i - 1][j]) {
          dp[i][j] = dp[i - 1][j];
          path[i][j] = make_pair(i - 1, j);
        }
        long long t = factor[j] / gcd(a[i], factor[j]);
        int p = table[t];
        pair<int, long long> st =
            make_pair(dp[i - 1][p].first + 1, dp[i - 1][p].second + a[i]);
        if (dp[i][j] > st) {
          dp[i][j] = st;
          path[i][j] = make_pair(i - 1, p);
        }
      }
    }
    if (dp[n][((int)factor.size()) - 1].first == INF)
      PL(-1);
    else {
      PL(dp[n][((int)factor.size()) - 1].first);
      pair<int, int> p(n, ((int)factor.size()) - 1);
      while (p.first && p.second) {
        if (path[p.first][p.second].second != p.second) PL(p.first);
        p = path[p.first][p.second];
      }
    }
  }
  return 0;
}
