Rotate an array

Read an array and an integer K. Rotate the array to the right by K positions and print it.

Reported in: Infosys (2021–25), Accenture (memory-based)

Input

First line: N. Second line: N integers. Third line: K.

Output

The rotated array, space-separated.

Constraints

1 ≤ N ≤ 10^5; 0 ≤ K ≤ 10^9.

Example 1

Input:
5
1 2 3 4 5
2

Output:
4 5 1 2 3

Example 2

Input:
3
7 8 9
4

Output:
9 7 8

Hint: Use K mod N; the element at index i moves to (i + K) mod N.

All coding practice