#include <bits/stdc++.h>
using namespace std;
const int N = 1005, D = 3e4;
long long a[N];
int anc[N][D];
pair<int, long long> dp[2][D];
vector<long long> v;
vector<int> ct, w;
int m;
int getMask(vector<int> &a) {
  int z = 0;
  for (int i = m - 1; i >= 0; i--) {
    z = z * (ct[i] + 1) + a[i];
  }
  return z;
}
int add(int x, int y) {
  int z = 0;
  for (int i = 0; i < m; i++) {
    z = z + min(ct[i], x % (ct[i] + 1) + y % (ct[i] + 1)) * w[i];
    x /= (ct[i] + 1);
    y /= (ct[i] + 1);
  }
  return z;
}
int main() {
  int n;
  long long k;
  scanf("%d%lld", &n, &k);
  int mn = 0;
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
    if (a[mn] > a[i]) mn = i;
  }
  if (k == 1) {
    printf("1\n%d", mn + 1);
    return 0;
  }
  int g = 1;
  for (long long i = 2; i * i <= k; i++) {
    if (k % i == 0) {
      v.push_back(i);
      int c = 0;
      while (k % i == 0) {
        k /= i;
        c++;
      }
      ct.push_back(c);
      g *= c + 1;
    }
  }
  if (k > 1) {
    v.push_back(k);
    ct.push_back(1);
    g *= 2;
  }
  g--;
  m = v.size();
  w.resize(m);
  w[0] = 1;
  for (int i = 1; i < m; i++) {
    w[i] = w[i - 1] * (ct[i - 1] + 1);
  }
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < D; j++) {
      dp[i][j] = {N, N};
    }
  }
  dp[0][0] = {0, 0};
  int q = 0;
  for (int i = 0; i < n; i++, q = 1 - q) {
    for (int j = 0; j < D; j++) {
      dp[1 - q][j] = {N, N};
    }
    long long x = a[i];
    int t = 0;
    for (int j = 0; j < m; j++) {
      int c = 0;
      while (x % v[j] == 0) {
        x /= v[j];
        c++;
      }
      t += c * w[j];
    }
    for (int j = 0; j <= g; j++) {
      if (dp[q][j].first != N) {
        auto val = dp[q][j];
        if (dp[1 - q][j] > val) {
          dp[1 - q][j] = val;
          anc[i + 1][j] = j;
        }
        val.first++;
        val.second += a[i];
        int nj = add(j, t);
        if (dp[1 - q][nj] > val) {
          dp[1 - q][nj] = val;
          anc[i + 1][nj] = j;
        }
      }
    }
  }
  int x = n, y = g;
  if (dp[q][y].first == N) {
    printf("-1");
    return 0;
  }
  printf("%d\n", dp[q][y].first);
  while (x > 0) {
    if (anc[x][y] != y) {
      printf("%d ", x);
    }
    y = anc[x][y];
    x--;
  }
  return 0;
}
