#include <bits/stdc++.h>
using namespace std;
long long inf_ = 0x7f7f7f7f7f7f7f7f;
int n, cnt, bf[1010][6720];
long long m, a[1010], division[6720], dp[6720];
inline long long gcd(long long a, long long b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
inline int search(const long long *div, int l, int r, const long long &t) {
  if (div[l] == t) return l;
  if (div[r] == t) return r;
  while (l <= r) {
    int m = (l + r) >> 1;
    if (div[m] == t) {
      return m;
    } else if (div[m] > t) {
      r = m - 1;
    } else {
      l = m + 1;
    }
  }
  cout << t << endl;
  exit(-1);
}
int main() {
  scanf("%d%lld", &n, &m);
  long long mini = inf_;
  int id = -1;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    if (mini >= a[i]) mini = a[id = i];
  }
  if (m == 1) {
    printf("1\n%d\n", id);
    return 0;
  }
  for (long long i = 1; i * i <= m; i++) {
    if (m % i) continue;
    division[cnt++] = i;
    if (i * i == m) continue;
    division[cnt++] = m / i;
  }
  sort(division, division + cnt);
  memset(dp, 0x7f, sizeof dp);
  dp[0] = 0;
  for (int i = 1; i <= n; i++) {
    long long b = gcd(a[i], m);
    for (int j = cnt - 1; ~j; j--) {
      int nj = search(division, j, cnt - 1,
                      gcd(division[cnt - 1 - j], b) * division[j]);
      long long tmp = dp[j] + (1LL << 50 | a[i]);
      bf[i][j] = j;
      if (dp[nj] > tmp) {
        dp[nj] = tmp;
        bf[i][nj] = j;
      }
    }
  }
  if (dp[cnt - 1] == inf_) {
    puts("-1");
  } else {
    vector<int> ans;
    int status = cnt - 1;
    for (int i = n; i; i--) {
      if (bf[i][status] != status) {
        status = bf[i][status];
        ans.push_back(i);
      }
    }
    printf("%d\n", int(ans.size()));
    for (unsigned int i = 0; i < ans.size(); i++) {
      printf("%d%c", ans[i], i + 1 == ans.size() ? '\n' : ' ');
    }
  }
  return 0;
}
