Linked List-K Append

This code is showing wrong answer in two test cases

@MG7
You have not worked for the testcases when K is greather than N.
Input :
7
1 2 2 1 8 5 6
10

Expected Output :
8 5 6 1 2 2 1

Consider taking the modulo of k with n.

now in 1 test case it is showing runtime error

I got the Mistake and now it has passed all the testcases
Thank you for Help