#include <bits/stdc++.h>
using namespace std;
const int INF = 1000 * 1000 * 1000;
const long long LINF = 1LL * INF * INF;
const int MAX = 100010;
const long double PI = acos(-1.);
const double EPS = 1e-6;
long long mod = 1000LL * 1000 * 1000 + 7;
map<int, vector<int> > foo;
vector<long long> arr;
bool cmp(int i, int j) { return arr[i] < arr[j]; }
int main() {
  ios_base::sync_with_stdio(0);
  int n, k;
  cin >> n >> k;
  arr.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
    long long p = 2;
    while (arr[i] >= p * p) {
      if (arr[i] % p == 0) {
        foo[p].push_back(i);
        while (arr[i] % p == 0) arr[i] /= p;
      }
      p++;
    }
  }
  int x = 2;
  for (auto it : foo) {
    if ((int)foo[x].size() < (int)it.second.size()) x = it.first;
  }
  if ((int)foo[x].size() >= k) {
    for (int i = 0; i < k; ++i) cout << foo[x][i] + 1 << " ";
  } else {
    set<int> foo2;
    for (int i = 0; i < n; ++i) foo2.insert(i);
    for (int i = 0; i < (int)foo[x].size(); ++i) foo2.erase(foo[x][i]);
    vector<int> ans;
    for (auto it : foo2) {
      ans.push_back(it);
    }
    sort(ans.begin(), ans.end(), cmp);
    for (int i = 0; i < k; ++i) cout << ans[i] + 1 << " ";
  }
  return 0;
}
