#include <bits/stdc++.h>
using namespace std;
const int P = 1e9 + 7, INF = 0x3f3f3f3f;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long qpow(long long a, long long n) {
  long long r = 1 % P;
  for (a %= P; n; a = a * a % P, n >>= 1)
    if (n & 1) r = r * a % P;
  return r;
}
long long inv(long long first) {
  return first <= 1 ? 1 : inv(P % first) * (P - P / first) % P;
}
const int N = 1e3 + 10, M = 7e3 + 10;
int n, sz;
long long k, a[N], b[N];
vector<long long> A;
map<long long, int> S;
pair<int, long long> dp[N][M];
int main() {
  scanf("%d%lld", &n, &k);
  for (int i = 1; i <= n; ++i) scanf("%lld", a + i), b[i] = gcd(a[i], k);
  if (k == 1)
    return printf("1\n%d\n", int(min_element(a + 1, a + 1 + n) - a)), 0;
  int mx = sqrt(k + 0.5);
  for (int i = 1; i <= mx; ++i)
    if (k % i == 0) {
      A.push_back(i);
      if (k / i != i) A.push_back(k / i);
    }
  sort(A.begin(), A.end());
  sz = A.size();
  for (int i = 0; i <= sz - 1; ++i) S[A[i]] = i;
  for (int i = 1; i <= sz - 1; ++i) dp[0][i] = pair<int, long long>(n + 1, 0);
  for (int i = 1; i <= n; ++i)
    for (int j = 0; j <= sz - 1; ++j) {
      long long pre = S[A[j] / gcd(A[j], b[i])];
      dp[i][j] = pair<int, long long>(dp[i - 1][pre].first + 1,
                                      dp[i - 1][pre].second + a[i]);
      dp[i][j] = min(dp[i][j], dp[i - 1][j]);
    }
  if (dp[n][sz - 1].first == n + 1) return puts("-1"), 0;
  printf("%d\n", dp[n][sz - 1].first);
  for (int i = n; i >= 1; --i)
    if (dp[i][S[k]] != dp[i - 1][S[k]]) {
      printf("%d ", i);
      k /= gcd(k, a[i]);
    }
  putchar(10);
}
