#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t--){
int n;
cin>>n;
int k;
cin>>k;
int a[n];
k=k%n;
for(int i=0;i<n;i++){
cin>>a[i];
}
int b[n]={0};
int c=0;
int s=n-k;
for(int i=s;i<n;i++){
b[c++]=a[i];
}
for(int i=0;i<s;i++){
b[c++]=a[i];
}
for(int i=0;i<n;i++){
cout<<b[i]<<" ";
}
cout<<"\n";
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZTxiaXRzL3N0ZGMrKy5oPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CgkvLyB5b3VyIGNvZGUgZ29lcyBoZXJlCglpbnQgdDsKCWNpbj4+dDsKCXdoaWxlKHQtLSl7CglpbnQgbjsKCWNpbj4+bjsKCWludCBrOwoJY2luPj5rOwoJaW50IGFbbl07CglrPWslbjsKCWZvcihpbnQgaT0wO2k8bjtpKyspewoJCWNpbj4+YVtpXTsKCX0KCWludCBiW25dPXswfTsKCWludCBjPTA7CglpbnQgcz1uLWs7Cglmb3IoaW50IGk9cztpPG47aSsrKXsKCQliW2MrK109YVtpXTsKCX0KCWZvcihpbnQgaT0wO2k8cztpKyspewoJCWJbYysrXT1hW2ldOwoJfQoJZm9yKGludCBpPTA7aTxuO2krKyl7CgkJY291dDw8YltpXTw8IiAiOwoJfQoJY291dDw8IlxuIjsKCX0KCXJldHVybiAwOwp9