#include <bits/stdc++.h>
using namespace std;
template <class X, class Y>
void minimize(X &x, const Y &y) {
  if (x > y) x = y;
}
template <class X, class Y>
void maximize(X &x, const Y &y) {
  if (x < y) x = y;
}
template <class T>
T Abs(const T &x) {
  return (x < 0 ? -x : x);
}
long long a[1111], k;
int n, numDiv, numFact;
vector<pair<long long, int> > facts;
vector<pair<int, long long> > f[1111];
vector<int> trc[1111];
vector<int> gain[1111];
vector<int> divInfo[14];
void init(void) {
  cin >> n >> k;
  for (int i = (1), _b = (n); i <= _b; i = i + 1) cin >> a[i];
  if (k == 1) {
    int idMin = 1;
    for (int i = (1), _b = (n); i <= _b; i = i + 1)
      if (a[i] < a[idMin]) idMin = i;
    printf("1\n%d\n", idMin);
    exit(0);
  }
}
vector<int> getGain(long long x) {
  vector<int> res;
  for (__typeof((facts).begin()) it = (facts).begin(); it != (facts).end();
       it++) {
    res.push_back(0);
    while (x % it->first == 0) {
      res.back()++;
      x /= it->first;
    }
  }
  return (res);
}
void prepare(void) {
  for (int i = 2; 1LL * i * i <= k; i = i + 1)
    if (k % i == 0) {
      facts.push_back(make_pair(i, 0));
      while (k % i == 0) {
        k /= i;
        facts.back().second++;
      }
    }
  if (k > 1) facts.push_back(make_pair(k, 1));
  numFact = facts.size();
  assert(numFact < 14);
  numDiv = 1;
  for (__typeof((facts).begin()) it = (facts).begin(); it != (facts).end();
       it++)
    numDiv *= it->second + 1;
  for (int i = 0, _n = (numFact); i < _n; i = i + 1)
    divInfo[i].assign(numDiv, 0);
  for (int i = 0, _n = (numDiv); i < _n; i = i + 1) {
    int code = i;
    for (int j = (numFact - 1), _a = (0); j >= _a; j = j - 1) {
      divInfo[j][i] = code % (facts[j].second + 1);
      code /= facts[j].second + 1;
    }
  }
  for (int i = (1), _b = (n); i <= _b; i = i + 1) gain[i] = getGain(a[i]);
}
int getNewDiv(int curDiv, const vector<int> &gain) {
  int code = 0;
  for (int i = 0, _n = (numFact); i < _n; i = i + 1) {
    int newDiv = min(divInfo[i][curDiv] + gain[i], facts[i].second);
    code = code * (facts[i].second + 1) + newDiv;
  }
  return (code);
}
void optimize(void) {
  for (int i = 0, _n = (n + 1); i < _n; i = i + 1)
    f[i].assign(numDiv, make_pair(n + 1, n + 1));
  for (int i = 0, _n = (n + 1); i < _n; i = i + 1) trc[i].assign(numDiv, -1);
  f[0][0] = make_pair(0, 0);
  for (int i = 0, _n = (n); i < _n; i = i + 1)
    for (int j = 0, _n = (numDiv); j < _n; j = j + 1)
      if (f[i][j].first <= n) {
        if (f[i + 1][j] > f[i][j]) {
          f[i + 1][j] = f[i][j];
          trc[i + 1][j] = -1;
        }
        int newDiv = getNewDiv(j, gain[i + 1]);
        pair<int, long long> newVal(f[i][j].first + 1,
                                    f[i][j].second + a[i + 1]);
        if (f[i + 1][newDiv] > newVal) {
          f[i + 1][newDiv] = newVal;
          trc[i + 1][newDiv] = j;
        }
      }
}
void trace(void) {
  if (f[n][numDiv - 1].first > n) {
    printf("-1\n");
    return;
  }
  vector<int> res;
  int j = numDiv - 1;
  for (int i = (n), _a = (1); i >= _a; i = i - 1) {
    if (f[i - 1][j] == f[i][j]) continue;
    res.push_back(i);
    j = trc[i][j];
  }
  printf("%d\n", (int)res.size());
  for (__typeof((res).begin()) it = (res).begin(); it != (res).end(); it++)
    printf("%d ", *it);
  printf("\n");
}
int main(void) {
  init();
  prepare();
  optimize();
  trace();
  return 0;
}
