#include <bits/stdc++.h>
using namespace std;
const int oo = 1e9;
const int mx = 1e3 + 10;
const int mxd = (1 << 13) + 10;
long long int a[mx], b[mx];
vector<long long int> divs;
pair<int, long long int> f[mx][mxd];
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  int n;
  long long int k;
  scanf("%d %lld", &n, &k);
  long long int g = k;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", a + i);
    b[i] = gcd(k, a[i]);
    g /= gcd(g, a[i]);
  }
  if (g != 1) {
    puts("-1");
    return 0;
  }
  if (k == 1) {
    puts("1");
    int idx = min_element(a + 1, a + 1 + n) - a;
    printf("%d\n", idx);
    return 0;
  }
  for (long long int d = 1; d * d <= k; d++) {
    if (k % d == 0) {
      divs.push_back(d);
      if (d != k / d) divs.push_back(k / d);
    }
  }
  sort(divs.begin(), divs.end());
  divs.resize(unique(divs.begin(), divs.end()) - divs.begin());
  int nd = divs.size();
  unordered_map<long long int, int> mp;
  for (int i = 0; i < int(divs.size()); i++) mp[divs[i]] = i;
  for (int d = 1; d < nd; d++) f[0][d] = pair<int, long long int>(oo, 0ll);
  for (int i = 1; i <= n; i++) {
    for (int d = 1; d < nd; d++) {
      f[i][d] = f[i - 1][d];
      long long int x = divs[d] / gcd(divs[d], b[i]);
      int idx = mp[x];
      pair<int, long long int> bet(f[i - 1][idx].first + 1,
                                   a[i] + f[i - 1][idx].second);
      f[i][d] = min(f[i][d], bet);
    }
  }
  int pos = n, x = nd - 1;
  printf("%d\n", f[n][nd - 1].first);
  int c = 0;
  while (c < f[n][nd - 1].first) {
    if (f[pos][x] == f[pos - 1][x])
      pos--;
    else {
      printf("%d ", pos);
      long long int nx = divs[x] / gcd(divs[x], b[pos]);
      x = mp[nx];
      pos--;
      c++;
    }
  }
  puts("");
  return 0;
}
