#include <bits/stdc++.h>
using namespace std;
long long int divs[(6800 + 1)];
int num1 = 0;
unordered_map<long long int, int> divMap;
pair<int, long long int> dp[1002][(6800 + 1)];
pair<int, int> link[1002][(6800 + 1)];
void getAllDivisors(long long int num) {
  int j = 0;
  int square_root = (int)sqrt(num) + 1;
  for (int i = 1; i < square_root; i++) {
    if (num % i == 0) {
      if (i * i != num) {
        divs[j++] = (i);
      }
      divs[j++] = (num / i);
    }
  }
  num1 = j;
  for (int i = 0; i < j; i++) divMap[divs[i]] = i;
}
long long int gcd(long long int x, long long int y) {
  if (x % y == 0)
    return y;
  else
    return gcd(y, x % y);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long int n, k;
  cin >> n >> k;
  getAllDivisors(k);
  long long int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  for (int j = 0; j < (6800 + 1); j++) dp[n][j] = {(1e9), (1e9)};
  dp[n][0] = {0, 0};
  long long int mini = 1e18, pos;
  if (k == 1) {
    for (int i = 0; i < n; i++)
      if (mini > arr[i]) mini = arr[i], pos = i + 1;
    cout << 1 << endl;
    cout << pos;
    return 0;
  }
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < num1; j++) {
      pair<int, long long int> &res = dp[i][j];
      res = {(1e9), 1e18};
      if (res.first > (dp[i + 1][j].first)) {
        res.first = (dp[i + 1][j].first);
        res.second = (dp[i + 1][j].second);
        link[i][j] = {i + 1, j};
      } else if (res.first == (dp[i + 1][j].first) &&
                 res.second > (dp[i + 1][j].second)) {
        res.second = (dp[i + 1][j].second);
        link[i][j] = {i + 1, j};
      }
      long long int a = arr[i], b = divs[j];
      int k = divMap[divs[j] / gcd(a, b)];
      if (res.first > (1 + dp[i + 1][k].first)) {
        res.first = (1 + dp[i + 1][k].first);
        res.second = (arr[i] + dp[i + 1][k].second);
        link[i][j] = {i + 1, k};
      } else if (res.first == (1 + dp[i + 1][k].first) &&
                 res.second > (arr[i] + dp[i + 1][k].second)) {
        res.second = (arr[i] + dp[i + 1][k].second);
        link[i][j] = {i + 1, k};
      }
    }
  }
  if (dp[0][divMap[k]].first == (1e9)) {
    cout << -1;
    return 0;
  }
  cout << dp[0][divMap[k]].first << endl;
  int num = 0, fact = divMap[k];
  while (fact != 0) {
    if (fact != link[num][fact].second) {
      cout << num + 1 << " ";
    }
    int f = fact;
    int n = num;
    fact = link[n][f].second;
    num = link[n][f].first;
  }
  return 0;
}
