#include <bits/stdc++.h>   using namespace std;   vector<int> primes;   int prime_marker[1000000];   void PrecomputePrimes() {     const int MAX_PRIME = 1000000;     for (int i = 2; i * i < MAX_PRIME; ++i) {       for (int j = i; i * j < MAX_PRIME; ++j) {         prime_marker[i * j] = 1;       }     }     for (int i = 2; i < MAX_PRIME; ++i) {       if (prime_marker[i]) continue;       primes.push_back(i);     }   }   vector<int64_t> prime_factors;   vector<int> factor_max_power;   void ComputePrimeFactors(int64_t val) {     for (int i = 0; i < primes.size(); ++i) {       if (val % primes[i] == 0) {         prime_factors.push_back(primes[i]);         factor_max_power.push_back(0);         while (val % primes[i] == 0) {           val /= primes[i];           factor_max_power.back()++;         }       }     }     if (val > 1000000) {       prime_factors.push_back(val);       factor_max_power.push_back(1);     }   }   vector<int64_t> arr;   vector<int> cofactor_power;   void ComputeCofactorPower(int64_t val) {     cofactor_power.resize(prime_factors.size());     for (int i = 0; i < prime_factors.size(); ++i) {       cofactor_power[i] = 0;       if (val % prime_factors[i] == 0) {         while (val % prime_factors[i] == 0) {           val /= prime_factors[i];           cofactor_power[i]++;         }       }     }   }   vector<int> basis;   void InitializeBasis() {     basis.resize(prime_factors.size());     basis[0] = 1;     for (int i = 1; i < prime_factors.size(); ++i) {       basis[i] = basis[i - 1] * (factor_max_power[i - 1] + 1);     }   }   void MapToIndices(int hash, vector<int>* indices) {     for (int i = basis.size() - 1; i >= 0; --i) {       (*indices)[i] = hash / basis[i];       hash -= (*indices)[i] * basis[i];     }   }   int IndicesToHash(const vector<int>& indices) {     int hash = 0;     for (int i = 0; i < indices.size(); ++i) {       hash += indices[i] * basis[i];     }     return hash;   }   vector<vector<int>> hash_indices;   void InitHashIndices(int max_hash) {     hash_indices.resize(max_hash, vector<int>(basis.size()));     for (int i = 0; i < max_hash; ++i) {       MapToIndices(i, &hash_indices[i]);     }   }   struct DpState {     int length = 100000;     int64_t cost = 0;     int parent;     bool is_chosen = false;     DpState(int length, int64_t cost, int parent, bool is_chosen)         : length(length), cost(cost), parent(parent), is_chosen(is_chosen) {}     DpState() {}     bool operator<(const DpState& other) const {       if (length == other.length) return cost < other.cost;       return length < other.length;     }   };   DpState dp[1003][7000];   void UpdateDP(int cur, int hash, const vector<int>& indices) {     if (cur == 0) {       if (hash == 0) {         dp[cur][hash] = DpState{0, 0, -1, false};         return;       }       bool is_divisible = true;       for (int i = 0; i < indices.size(); ++i) {         if (indices[i] > cofactor_power[i]) {           is_divisible = false;           break;         }       }       if (is_divisible) {         dp[cur][hash] = DpState{1, arr[cur], -1, true};       }       return;     }     vector<int> prev_indices(indices.size());     for (int i = 0; i < indices.size(); ++i) {       prev_indices[i] = max(0, indices[i] - cofactor_power[i]);     }     int prev_hash = IndicesToHash(prev_indices);     DpState state1 = {dp[cur - 1][prev_hash].length + 1,                       dp[cur - 1][prev_hash].cost + arr[cur], prev_hash, true};     DpState state2 = {dp[cur - 1][hash].length, dp[cur - 1][hash].cost, hash,                       false};     if (state1 < state2) {       dp[cur][hash] = state1;     } else {       dp[cur][hash] = state2;     }   }   int main() {     int n;     int64_t k;     PrecomputePrimes();     scanf( %d , &n);     cin >> k;     int64_t val;     for (int i = 0; i < n; ++i) {       cin >> val;       arr.push_back(val);     }     if (k == 1) {       int lowest_index = 0;       for (int i = 1; i < n; ++i) {         if (arr[i] < arr[lowest_index]) lowest_index = i;       }       printf( 1 n%d n , lowest_index + 1);       return 0;     }     ComputePrimeFactors(k);     InitializeBasis();     int max_hash = basis.back() * (factor_max_power.back() + 1);     InitHashIndices(max_hash);     for (int i = 0; i < n; ++i) {       ComputeCofactorPower(arr[i]);       for (int hash = 0; hash < max_hash; ++hash) {         UpdateDP(i, hash, hash_indices[hash]);       }     }     int cur_hash = max_hash - 1;     if (dp[n - 1][cur_hash].length >= 100000) {       printf( -1 n );       return 0;     }     printf( %d n , dp[n - 1][cur_hash].length);     for (int i = n - 1; i >= 0; --i) {       if (dp[i][cur_hash].is_chosen) {         printf( %d  , i + 1);       }       cur_hash = dp[i][cur_hash].parent;     }     printf(  n );     return 0;   }