#K35092. Rotate Array

    ID: 25454 Type: Default 1000ms 256MiB

Rotate Array

Rotate Array

You are given an array of integers and an integer D. The goal is to rotate the array to the left by D positions. In other words, the first D elements move to the end of the array in the same order. For example, if \(array = [1, 2, 3, 4, 5]\) and \(D = 2\), the resulting array should be \([3, 4, 5, 1, 2]\).

If \(D\) is greater than the number of elements \(N\) in the array, then the effective rotation is \(D \mod N\). Your task is to implement this rotation for multiple test cases.

inputFormat

The first line of input contains an integer T, the number of test cases. Each test case consists of two lines. The first line of a test case contains two space-separated integers, N (the number of elements in the array) and D (the number of positions to rotate the array). The second line contains N space-separated integers representing the array elements.

outputFormat

For each test case, output a single line representing the rotated array with its elements separated by a space.

## sample
3
5 2
1 2 3 4 5
4 4
10 20 30 40
7 3
10 20 30 40 50 60 70
3 4 5 1 2

10 20 30 40 40 50 60 70 10 20 30

</p>