#include <bits/stdc++.h>
using namespace std;
struct Item {
  int length;
  long long sum;
};
const bool operator<(const Item &v1, const Item &v2) {
  return v1.length < v2.length || ((v1.length == v2.length) && v1.sum < v2.sum);
}
const bool operator==(const Item &v1, const Item &v2) {
  return !(v1 < v2) && !(v2 < v1);
}
const bool operator>(const Item &v1, const Item &v2) { return v2 < v1; }
void re() { vector<int> b(1e10); }
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
const int N = 3e4;
const int L = 1002;
unordered_map<long long, int> dict;
long long invdict[N];
Item knapsack[2][N];
int dp[L][N];
Item INF = {1002, -1};
int sz = 1;
vector<pair<long long, long long> > prime;
long long big_gcd(long long k, long long a, long long b) {
  long long mul = a * b;
  if (mul / a == b) return gcd(k, a * b);
  long long res = 1;
  for (pair<long long, long long> p : prime) {
    while (a % p.first == 0 && p.second) {
      res *= p.first;
      --p.second;
      a /= p.first;
    }
    while (b % p.first == 0 && p.second) {
      res *= p.first;
      --p.second;
      b /= p.first;
    }
    if (a == 1 && b == 1) break;
  }
  return res;
}
void prec(long long k) {
  for (long long i = 2; i * i <= k; ++i) {
    int cnt = 0;
    while (k % i == 0) {
      ++cnt;
      k /= i;
    }
    prime.push_back(make_pair(i, cnt));
  }
  if (k != 1) prime.push_back(make_pair(k, 1));
  sort(prime.begin(), prime.end());
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  set<long long> divisors;
  int n;
  long long k;
  cin >> n >> k;
  prec(k);
  divisors.insert(1);
  divisors.insert(k);
  for (int i = 0; i < L; ++i) fill(dp[i], dp[i] + N, -1);
  for (long long i = 2; i * i <= k; ++i)
    if (k % i == 0) {
      divisors.insert(i);
      divisors.insert(k / i);
    }
  if (divisors.size() >= N) re();
  int cnt = 0;
  for (long long divisor : divisors) {
    invdict[cnt] = divisor;
    dict[divisor] = cnt++;
  }
  for (int z : {0, 1}) fill(knapsack[z], knapsack[z] + N, INF);
  int p = 0;
  int c = 1;
  knapsack[p][0] = {0, 0};
  int ind = 0;
  long long mn = -1;
  for (int i = 0; i < n; ++i, swap(p, c)) {
    long long cur;
    cin >> cur;
    if (!i) mn = cur;
    if (mn > cur) {
      mn = cur;
      ind = i;
    }
    for (int j = 0; j < sz; ++j) knapsack[c][j] = knapsack[p][j];
    long long g = gcd(cur, k);
    int nsz = sz;
    for (int j = 0; j < sz; ++j) {
      if (knapsack[p][j] == INF) continue;
      long long val = big_gcd(k, g, invdict[j]);
      int nx = dict[val];
      nsz = max(nsz, nx + 1);
      knapsack[p][j];
      Item prop = knapsack[p][j];
      ++prop.length;
      prop.sum += cur;
      if (knapsack[c][nx] > prop) {
        knapsack[c][nx] = prop;
        dp[i][nx] = j;
      }
    }
    sz = nsz;
  }
  if (k == 1) {
    cout << "1\n";
    cout << ind + 1;
    return 0;
  }
  if (knapsack[p][cnt - 1] == INF) {
    cout << "-1";
    return 0;
  }
  cout << knapsack[p][cnt - 1].length << "\n";
  int cur = cnt - 1;
  vector<int> ans;
  for (int i = n - 1; i >= 0; --i) {
    if (dp[i][cur] != -1) {
      ans.push_back(i);
      cur = dp[i][cur];
    }
  }
  if (ans.size() != knapsack[p][cnt - 1].length) re();
  for (int i = ans.size() - 1; i >= 0; --i) cout << ans[i] + 1 << " ";
}
