#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
int n;
long long k, a[maxn], b[maxn];
map<long long, int> mp;
vector<long long> v;
pair<long long, long long> f[maxn][8000];
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int main(void) {
  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) {
    puts("1");
    long long mini = a[1];
    int ans = 1;
    for (int i = 2; i <= n; i++) {
      if (a[i] < mini) {
        mini = a[i];
        ans = i;
      }
    }
    printf("%d\n", ans);
    return 0;
  }
  int top = sqrt(k + 0.5);
  for (int i = 1; i <= top; i++) {
    if (k % i == 0) {
      v.push_back(i);
      if (k / i != i) v.push_back(k / i);
    }
  }
  sort(v.begin(), v.end());
  int m = v.size() - 1;
  for (int i = 0; i <= m; i++) {
    mp[v[i]] = i;
  }
  for (int i = 1; i <= m; i++) {
    f[0][i] = {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 temp = mp[v[j] / gcd(b[i], v[j])];
      pair<long long, long long> t = pair<long long, long long>(
          f[i - 1][temp].first + 1, f[i - 1][temp].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][mp[k]] != f[i - 1][mp[k]]) {
        printf("%d ", i);
        k /= gcd(k, b[i]);
      }
    }
    puts("");
  }
}
