#include <bits/stdc++.h>
using namespace std;
const int N = 1e7 + 9;
vector<int> d[N];
int n, k, p, a[N];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    for (int j = 2; j * j <= a[i]; ++j)
      if (a[i] % j == 0) {
        for (d[j].push_back(i); a[i] % j == 0;) a[i] /= j;
        if (d[p].size() < d[j].size()) p = j;
      }
  }
  if (d[p].size() < k) {
    vector<pair<int, int>> ans;
    for (int i = 0, j = 0; i < n; ++i) {
      while (j < d[p].size() && d[p][j] < i) ++j;
      if (j == d[p].size() || d[p][j] > i) ans.emplace_back(a[i], i);
    }
    sort(ans.begin(), ans.end());
    for (int i = 0; i < k; ++i) printf("%d ", ans[i].second + 1);
  } else
    for (int i = 0; i < k; ++i) printf("%d ", d[p][i] + 1);
}
