#include<bits/stdc++.h>
using namespace std;
int ok =1;
void result(int k,int x[]){
for(int i =1; i <= k;i++){
cout << x[i];
}
cout << " ";
}
void next(int n, int k, int x[]){
int i = k;
while(i > 0 && x[i] == n - k + i){
i--;
}
if(i > 0){
x[i] = x[i]+1;
for(int j = i + 1; j <=k; j++){
x[j] = x[j-1]+1;
}
}
else {
ok =0;
}
}
int main(){
int t;
cin >> t;
while(t--){
int n, k;
cin >> n >> k;
int x[100];
for(int i =1; i <= k;i++){
x[i] = i;
}ok =1;
while(ok){
result(k,x);
next(n,k,x);
}
cout << endl;
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IG9rID0xOwp2b2lkIHJlc3VsdChpbnQgayxpbnQgeFtdKXsKCWZvcihpbnQgaSA9MTsgaSA8PSBrO2krKyl7CgkJY291dCA8PCB4W2ldOwoJfQoJY291dCA8PCAiICI7Cn0Kdm9pZCBuZXh0KGludCBuLCBpbnQgaywgaW50IHhbXSl7CglpbnQgaSA9IGs7Cgl3aGlsZShpID4gMCAmJiB4W2ldID09IG4gLSBrICsgaSl7CgkJaS0tOwoJfQoJaWYoaSA+IDApewoJCXhbaV0gPSB4W2ldKzE7CgkJZm9yKGludCBqID0gaSArIDE7IGogPD1rOyBqKyspewoJCQl4W2pdID0geFtqLTFdKzE7CgkJfQoJfQoJZWxzZSB7CgkJb2sgPTA7Cgl9Cn0KaW50IG1haW4oKXsKCWludCB0OwoJY2luID4+IHQ7Cgl3aGlsZSh0LS0pewoJCWludCBuLCBrOwoJCWNpbiA+PiBuID4+IGs7CgkJaW50IHhbMTAwXTsKCQlmb3IoaW50IGkgPTE7IGkgPD0gaztpKyspewoJCQl4W2ldID0gaTsKCQl9b2sgPTE7CgkJd2hpbGUob2spewoJCQlyZXN1bHQoayx4KTsKCQkJbmV4dChuLGsseCk7CgkJfQoJCWNvdXQgPDwgZW5kbDsKCX0KfQ==