#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define len(a) int((a).size())
void solve(int /* test_num */) {
int n, m;
cin >> n >> m;
map<int, set<int>> mp;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
mp[a[i]].insert(i);
}
sort(all(a));
if (m == n - 1) {
cout << "1\n";
return;
}
if (m == 0) {
for (int i = 1; i <= n; i++) {
cout << i << " \n"[i == n];
}
return;
}
map<int, set<int>> cur;
auto take = [&](int val) {
auto &st = mp[val];
assert(!st.empty());
int res = *st.begin();
st.erase(st.begin());
cur[val].insert(res);
return res;
};
auto rem = [&](int val) {
auto &st = cur[val];
assert(!st.empty());
int res = *st.rbegin();
st.erase(prev(st.end()));
mp[val].insert(res);
return res;
};
auto f = [&](ll sum, ll sum2) {
return (n - m) * sum2 - sum * sum;
};
vector<bool> ans(n);
ll best_sum = 0, best_sum2 = 0;
for (int i = 0; i < n - m; i++) {
best_sum += a[i];
best_sum2 += a[i] * a[i];
ans[take(a[i])] = true;
}
ll cur_sum = best_sum, cur_sum2 = best_sum2;
set<int> del, ins;
for (int i = n - m - 1, j = n - 1; i >= 0; i--, j--) {
cur_sum -= a[i];
cur_sum2 -= a[i] * a[i];
cur_sum += a[j];
cur_sum2 += a[j] * a[j];
int p1 = rem(a[i]);
int p2 = take(a[j]);
if (p1 != p2) {
del.erase(p1), ins.erase(p1);
del.erase(p2), ins.erase(p2);
if (ans[p1]) {
del.insert(p1);
}
if (!ans[p2]) {
ins.insert(p2);
}
}
assert(len(del) == len(ins));
ll cur_f = f(cur_sum, cur_sum2);
ll sum_f = f(best_sum, best_sum2);
if (cur_f > sum_f || (cur_f == sum_f && !del.empty() && *ins.begin() < *del.begin())) {
best_sum = cur_sum;
best_sum2 = cur_sum2;
for (auto x : del) {
ans[x] = false;
}
for (auto x : ins) {
ans[x] = true;
}
del.clear();
ins.clear();
}
}
assert(count(all(ans), true) == n - m);
bool first = true;
for (int i = 0; i < n; i++) {
if (ans[i]) {
if (first) {
first = false;
} else {
cout << ' ';
}
cout << i + 1;
}
}
cout << '\n';
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int tests;
cin >> tests;
for (int test_num = 1; test_num <= tests; test_num++) {
solve(test_num);
}
}