#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
const int M = 7e3 + 10;
int n, cnt;
int c[N][M], f[N][M];
int fg = 0;
unordered_map<long long, int> mp;
long long a[N];
long long s[N][M], d[M];
long long k, now;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
void solve(long long x) {
  long long now = sqrt(x);
  cnt = 0;
  for (int i(1); i <= (now); ++i) {
    if (x % i == 0) {
      if (i * i != x) {
        d[++cnt] = i;
        d[++cnt] = x / i;
      } else
        d[++cnt] = i;
    }
  }
  sort(d + 1, d + cnt + 1);
}
int main() {
  scanf("%d%lld", &n, &k);
  for (int i(1); i <= (n); ++i) scanf("%lld", a + i);
  if (k == 1ll)
    return 0 * printf("%d\n%lld\n", 1, min_element(a + 1, a + n + 1) - a);
  solve(k);
  for (int i(1); i <= (cnt); ++i) mp[d[i]] = i;
  f[1][1] = 0;
  for (int i(2); i <= (cnt); ++i)
    if (a[1] % d[i] == 0) {
      f[1][i] = 1;
      s[1][i] = a[1];
    } else
      f[1][i] = 1e7;
  for (int i(1); i <= (n); ++i)
    for (int j(1); j <= (cnt); ++j) c[i][j] = mp[d[j] / gcd(d[j], a[i])];
  for (int i(2); i <= (n); ++i) {
    for (int j(1); j <= (cnt); ++j) {
      f[i][j] = f[i - 1][j];
      s[i][j] = s[i - 1][j];
      long long val = c[i][j];
      if (f[i][j] > f[i - 1][val] + 1) {
        f[i][j] = f[i - 1][val] + 1;
        s[i][j] = s[i - 1][val] + a[i];
      } else if (f[i][j] == f[i - 1][val] + 1 &&
                 s[i][j] > s[i - 1][val] + a[i]) {
        s[i][j] = s[i - 1][val] + a[i];
      }
    }
  }
  if (f[n][cnt] > n) return 0 * puts("-1");
  printf("%d\n", f[n][cnt]);
  now = k;
  for (int i(n); i >= (1); --i) {
    int et = mp[now];
    if (f[i][et] == f[i - 1][et] && s[i][et] == s[i - 1][et]) continue;
    now /= gcd(now, a[i]);
    if (fg)
      putchar(32);
    else
      fg = 1;
    printf("%d", i);
  }
  return 0 * putchar(10);
}
