#include<bits/stdc++.h>
using namespace std;
struct app{
int num;
int index;
};
bool compare(const app& a, const app& b) {
return a.num< b.num;
}
int main(){
int t;
cin>>t;
while(t--) {
int n,k;
cin>>n>>k;
app A[n];
for (int i = 0; i < n; i++){
cin >> A[i].num;
A[i].index=i;
}
for(int i=0;i<n;i++){
A[i].num=(A[i].num)%k;
}
sort(A,A+n,compare);
k++;
for(int i=0;i<n;i++)
cout<<A[i].index+1<<" ";
cout<<"\n";
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KICAgIHVzaW5nIG5hbWVzcGFjZSBzdGQ7CnN0cnVjdCBhcHB7CiAgICBpbnQgbnVtOwogICAgaW50IGluZGV4Owp9Owpib29sIGNvbXBhcmUoY29uc3QgYXBwJiBhLCBjb25zdCBhcHAmIGIpIHsKICAgIHJldHVybiBhLm51bTwgYi5udW07Cn0KCiAgICBpbnQgbWFpbigpewogICAgICAgIGludCB0OwogICAgICAgIGNpbj4+dDsKICAgICAgICB3aGlsZSh0LS0pIHsKICAgICAgICAgICAgaW50IG4sazsKICAgICAgICAgICAgY2luPj5uPj5rOwogICAgICAgICAgICBhcHAgQVtuXTsKICAgICAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspewogICAgICAgICAgICAgICAgY2luID4+IEFbaV0ubnVtOwogICAgICAgICAgICAgICAgQVtpXS5pbmRleD1pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGZvcihpbnQgaT0wO2k8bjtpKyspewogICAgICAgICAgICAgICAgICAgIEFbaV0ubnVtPShBW2ldLm51bSklazsKCiAgICAgICAgICAgIH0KICAgICAgICAgICAgc29ydChBLEErbixjb21wYXJlKTsKICAgICAgICAgICAgaysrOwogICAgICAgICAgICBmb3IoaW50IGk9MDtpPG47aSsrKQogICAgICAgICAgICAgICAgY291dDw8QVtpXS5pbmRleCsxPDwiICI7CiAgICAgICAgICAgIGNvdXQ8PCJcbiI7CiAgICAgICAgfQogICAgfQ==