3.1 Pearl Shuffle in Sparkleville
Score: 10pts
Time Limit: 5.00 sec
In the enchanted kingdom of Sparkleville, there exists a legendary necklace known far and wide for its dazzling pearls. This isn't just any necklace—each of the n pearls is enchanted with a unique charm that makes it sparkle with its own special number. The necklace is a treasure of the realm, admired by all for its beauty and magic.
One day, the mischievous pixies of Sparkleville decide they want to play a prank on their friend, the Kingdom’s most fashionable wizard. They sprinkle a bit of their playful magic on the necklace, causing it to perform a whimsical dance. The spell they cast makes each pearl move k places to the left, but with a twist: the pearls that fall off the end don’t just disappear—they reappear at the beginning in a delightfully mischievous shuffle.
For example: if the necklace was originally 1,5,3,4,2 and k=2now it becomes
3,4,2,1,5.

Constraints
Constraints:
1≤T≤100
1≤n≤10^5
The sum of n over all test cases does not exceed 3× 10^5
-10^9 <= ai<= 10^9

Input Format
First line will contain T, the number of test cases. Then the test cases follow.
Each test case contains two lines of input, the first containing two integers n,k
The second line of each test case contains n integers a1,a2,…,an ​ representing the integers on the pearls starting from the first one.

Output Format
For each testcase, output in a single line n integers representing the necklace after modification.

Example 1
Input:
2
5 3
1 5 3 4 2
6 5
10 1 2 9 8 2

Output:
4 2 1 5 3
2 10 1 2 9 8

Explanation:
For each testcase, output in a single line n integers representing the necklace after modification.

Log In to solve the Question