#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5;
vector<long long> v;
map<long long, int> id;
pair<long long, long long> f[N][8000];
long long n, k, m;
void init() {
  v.clear();
  for (long long i = 1; i * i <= k; i++) {
    if (k % i == 0) {
      v.push_back(i);
      if (i * i != k) v.push_back(k / i);
    }
  }
  sort(v.begin(), v.end());
  m = v.size() - 1;
  id.clear();
  for (int i = 0; i <= m; i++) id[v[i]] = i;
}
long long a[N], b[N];
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
int main() {
  while (cin >> n >> k) {
    init();
    for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]), b[i] = gcd(a[i], k);
    if (k == 1) {
      puts("1");
      printf("%d\n", min_element(a + 1, a + 1 + n) - a);
      continue;
    }
    for (int j = 1; j <= m; j++) f[0][j] = pair<long long, long long>(n + 1, 0);
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j <= m; j++) {
        f[i][j] = f[i - 1][j];
        int pre = id[v[j] / gcd(v[j], b[i])];
        pair<long long, long long> t = pair<long long, long long>(
            f[i - 1][pre].first + 1, f[i - 1][pre].second + a[i]);
        f[i][j] = min(f[i][j], t);
      }
    }
    if (f[n][m].first > n)
      puts("-1");
    else {
      printf("%d\n", f[n][m].first);
      for (int i = n; i >= 1; i--) {
        if (f[i][id[k]] != f[i - 1][id[k]]) {
          printf("%d ", i);
          k /= gcd(k, b[i]);
        }
      }
    }
    printf("\n");
  }
  return 0;
}
