Skip to lesson

Rotate the leaderboard by k

A medium problem for practising 5.4 Array & String Techniques. Solve it in your own IDE, check it against every test, and open a hint only when you are stuck. 0/1 solved.

1. Rotate the leaderboard by k

medium

The college quiz app shows a leaderboard of n player IDs on the notice-board screen. Every minute, each ID moves one place to the right, and the last ID wraps around to the first place.

Given the board now and the number of minutes k, print the board after k minutes. The screen may run for a very long time, so k can be much larger than n.

Input: The first line has two integers n and k. The second line has n integers: the player IDs, from first place to last place.

Output: One line with n integers separated by single spaces: the board after k minutes.

Limits: 1 ≤ n ≤ 10^5 · 0 ≤ k ≤ 10^18 · 1 ≤ player ID ≤ 10^9

Example 1

Input

5 2
11 22 33 44 55

Output

44 55 11 22 33

After 1 minute: 55 11 22 33 44. After 2 minutes: 44 55 11 22 33.

Example 2

Input

3 7
4 5 6

Output

6 4 5

Every 3 minutes the board is back to the start, so 7 minutes act like 1 minute.

Submit to solve