#include <bits/stdc++.h>
using namespace std;
vector<long long int> primes;
long long int a[1010], gc[1010];
long long int dp[1010][10000];
long long int pre[1010][10000];
long long int sum[1010][10000];
unordered_map<long long int, long long int> key;
long long int gcd(long long int a, long long int b) {
  return b == 0 ? a : gcd(b, a % b);
}
long long int cnt = 0;
long long int solve(long long int f, long long int s) {
  long long int ss;
  unordered_map<long long int, long long int>::iterator it1 = key.find(s);
  if (it1 == key.end()) {
    key[s] = cnt++;
    ss = cnt - 1;
  } else {
    ss = it1->second;
  }
  if (dp[f][ss] != 0) {
    return dp[f][ss];
  } else if (f == 0) {
    if (s == 1) {
      return 0;
    } else
      return 1e15;
  }
  if (s == 1) {
    return 0;
  }
  long long int res = solve(f - 1, s);
  long long int div = gcd(s, gc[f]);
  if (div == 1) {
    pre[f][ss] = s;
    sum[f][ss] = sum[f - 1][ss];
    return dp[f][ss] = res;
  }
  unordered_map<long long int, long long int>::iterator it = key.find(s / div);
  long long int next_ss;
  if (it == key.end()) {
    key[s / div] = cnt;
    next_ss = cnt++;
  } else {
    next_ss = it->second;
  }
  long long int res2 = solve(f - 1, s / div) + 1;
  if (res2 < res) {
    pre[f][ss] = s / div;
    res = res2;
    sum[f][ss] = sum[f - 1][next_ss] + a[f];
  } else if (res2 == res) {
    if (sum[f - 1][ss] > sum[f - 1][next_ss] + a[f]) {
      sum[f][ss] = sum[f - 1][next_ss] + a[f];
      res = res2;
      pre[f][ss] = s / div;
    } else {
      sum[f][ss] = sum[f - 1][ss];
      pre[f][ss] = s;
    }
  } else {
    sum[f][ss] = sum[f - 1][ss];
    pre[f][ss] = s;
  }
  return dp[f][ss] = res;
}
int main() {
  ios::sync_with_stdio(false);
  long long int n, k;
  cin >> n >> k;
  long long int kk = k;
  if (k == 1) {
    long long int mini = 1e18;
    long long int idx;
    for (int i = 1; i <= n; i++) {
      long long int temp;
      cin >> temp;
      if (mini > temp) {
        mini = temp;
        idx = i;
      }
    }
    cout << 1 << endl;
    cout << idx << endl;
    return 0;
  }
  while (k % 2 == 0) {
    primes.push_back(2);
    k /= 2;
  }
  for (long long int i = 3; i * i <= k; i += 2) {
    while (k % i == 0) {
      primes.push_back(i);
      k /= i;
    }
  }
  if (k != 0) {
    primes.push_back(k);
  }
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    gc[i] = 1;
    long long int t = a[i];
    for (long long int j : primes) {
      if (t % j == 0) {
        gc[i] *= j;
        t /= j;
      }
      if (t == 1) {
        break;
      }
    }
  }
  long long int ans = solve(n, kk);
  if (ans >= 1e15) {
    cout << -1 << endl;
    return 0;
  }
  cout << ans << endl;
  long long int cur = kk;
  for (int i = n; i >= 1; i--) {
    if (pre[i][key[cur]] != cur && cur != 1) {
      cout << i << " ";
      cur = pre[i][key[cur]];
    }
  }
  cout << endl;
}
