#include <iostream>
using namespace std;
int main() {
int t; cin >> t;
while(t--){
int n, k; cin >> n >> k;
int a[n];
for(int i=0; i<n; i++) a[i] = n-i;
for(int i=0; i<n-k; i++) cout << a[i] << " ";
for(int i=1; i<=k+1; i++) cout << k << " ";
cout << endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CglpbnQgdDsgY2luID4+IHQ7Cgl3aGlsZSh0LS0pewoJCWludCBuLCBrOyBjaW4gPj4gbiA+PiBrOwoJCWludCBhW25dOwoJCWZvcihpbnQgaT0wOyBpPG47IGkrKykgYVtpXSA9IG4taTsKCQlmb3IoaW50IGk9MDsgaTxuLWs7IGkrKykgY291dCA8PCBhW2ldIDw8ICIgIjsKCQlmb3IoaW50IGk9MTsgaTw9aysxOyBpKyspIGNvdXQgPDwgayA8PCAiICI7CgkJY291dCA8PCBlbmRsOwoJfQoJcmV0dXJuIDA7Cn0=