#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
double PI = 3.1415926535897932384626433832795;
long double EPS = 1e-12;
const int MOD = 1e9 + 7;
const int BASE = 1327;
const int MAXN = 1001;
int n;
long long k;
struct state {
  long long sum;
  int id, cnt, from;
  state() {}
  state(int cnt, long long sum, int from, int id)
      : cnt(cnt), id(id), from(from), sum(sum) {}
};
unordered_map<long long, int> id;
long long mas[MAXN];
long long org[MAXN];
long long name[11000];
state d[MAXN][11000];
inline long long gcd(long long a, long long b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
int ans[MAXN], en = 0;
void solve() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> mas[i];
    org[i] = mas[i];
    mas[i] = gcd(k, mas[i]);
  }
  for (long long i = 1; i * i <= k; ++i) {
    if (k % i == 0) {
      long long cur = i;
      if (id.find(cur) == id.end()) {
        int t = id.size();
        id[cur] = t;
        name[t] = cur;
      }
      cur = k / i;
      if (id.find(cur) == id.end()) {
        int t = id.size();
        id[cur] = t;
        name[t] = cur;
      }
    }
  }
  if (k == 1) {
    long long ans = 1e18;
    int id = -1;
    for (int j = 0; j < n; ++j) {
      if (org[j] < ans) {
        ans = org[j];
        id = j;
      }
    }
    cout << 1 << endl;
    cout << id + 1;
    return;
  }
  d[0][0] = state(1, 0, -1, -1);
  id[1] = 0;
  name[0] = 1;
  for (int i = 0; i < n; ++i) {
    int tn = id.size();
    for (int j = 0; j < tn; ++j) d[i + 1][j] = d[i][j];
    if (mas[i] == 1) continue;
    long long tr = k / mas[i];
    for (int j = 0; j < tn; ++j) {
      if (d[i][j].cnt == 0) continue;
      state cur = d[i][j];
      long long nex = gcd(tr, name[j]) * mas[i];
      nex = id[nex];
      state snex = d[i + 1][nex];
      if (snex.cnt == 0 || snex.cnt > cur.cnt + 1 ||
          (snex.cnt == cur.cnt + 1 && snex.sum > cur.sum + org[i])) {
        d[i + 1][nex] = state(cur.cnt + 1, cur.sum + org[i], j, i);
      }
    }
  }
  k = id[k];
  if (d[n][k].cnt != 0) {
    state cur = d[n][k];
    long long t = 0;
    en = 0;
    ans[en++] = cur.id;
    t = cur.from;
    while (t != 0) {
      ans[en] = d[ans[en - 1]][t].id;
      t = d[ans[en - 1]][t].from;
      en++;
    }
  } else {
    cout << -1;
    return;
  }
  cout << en << endl;
  for (int i = 0; i < en; ++i) {
    cout << ans[i] + 1 << ' ';
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  srand(1313);
  int t = 1;
  for (int i = 0; i < t; ++i) {
    solve();
  }
  return 0;
}
