#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) { return x ? gcd(y % x, x) : y; }
pair<int, long long> dp[1005][7005];
long long divisors[7005];
map<long long, int> pos;
bool mark[1005][7005];
long long cost[1005];
int n;
long long ggg[1005];
pair<int, long long> calc(int now, int p) {
  if (p == 0) return make_pair(0, 0);
  if (now == n) return make_pair(-1, -1);
  pair<int, long long> &ret = dp[now][p];
  if (ret.first != -2) return ret;
  ret = calc(now + 1, p);
  pair<int, long long> xxx =
      calc(now + 1, pos[divisors[p] / gcd(ggg[now], divisors[p])]);
  if (xxx.first == -1) return ret = make_pair(-1, -1);
  xxx.first++;
  xxx.second += cost[now];
  if (xxx < ret || ret.first == -1) {
    ret = xxx;
    mark[now][p] = 1;
  }
  return ret;
}
void go(int now, int p) {
  if (p == 0) return;
  if (!mark[now][p]) {
    go(now + 1, p);
    return;
  }
  printf("%d ", now + 1);
  go(now + 1, pos[divisors[p] / gcd(divisors[p], cost[now])]);
  return;
}
int main() {
  int cnt = 0;
  long long i, k, mn = 100000000000000ll, minpos;
  scanf("%d%I64d", &n, &k);
  for (i = 1; i * i <= k; i++) {
    if (k % i == 0) {
      divisors[cnt] = i;
      pos[i] = cnt++;
      if (i * i != k) {
        divisors[cnt] = k / i;
        pos[k / i] = cnt++;
      }
    }
  }
  for (i = 0; i < n; i++) {
    scanf("%I64d", &cost[i]);
    ggg[i] = gcd(cost[i], k);
    if (cost[i] < mn) {
      mn = cost[i];
      minpos = i + 1;
    }
  }
  if (k == 1) {
    printf("1\n%d\n", minpos);
    return 0;
  }
  for (i = 0; i < n; i++)
    for (int j = 0; j < cnt; j++) dp[i][j] = make_pair(-2, -2);
  pair<int, long long> ans = calc(0, pos[k]);
  if (ans.first == -1) {
    printf("-1\n");
    return 0;
  }
  printf("%d\n", ans.first);
  go(0, pos[k]);
  printf("\n");
  return 0;
}
