/*The first line will consist of one integer T denoting the number of test cases. For each test case:
- The first line consists of two integers n and r, n being the number of elements in the array and r denotes the number of steps of rotation.
- The next line consists of N space-separated integers, denoting the elements of the array a.
Constraints:
1<=t<=20
1<=n<=10^5
0<=k<=10^6
0<=a[i]<=10^6
Input
1
5 2
1 2 3 4 5 6
Output
4 5 1 2 3 */
// my code
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
int t,n,r;
cin>>t;
for (int i = 0; i < t; i++)
{
cin >> n >> r; // inputting number of element in array and number of rotation
int a[n];
for (int i = 0; i < n; i++)
{
cin>>a[i]; //taking input from user in array
}
n--;
for (int i = 0; i < r; i++)
{
n++;
for (int i = n; i >= 0; i--)
{
a[i]=a[i-1];
} // help me to improve this inner loop and add a little bit
a[0]=a[n]; //of explanation for your logic and pls give answer in c++
n--;
}
for (int i = 0; i <= n; i++)
{
cout<<a[i]<<" ";
}
cout<<endl;
}
return 0;
}