



The first line contains a single integer ‘T’ representing the number of test cases.
The first line of each test case will contain the elements of the linked list separated by a single space and terminated by -1. Hence, -1 would never be a list element.
For each test case, return the new head node of the linked list after adding the last node to its front.
Print the output of each test case in a separate line.
You don’t need to print anything, It has already been taken care of. Just implement the given function.
1 <= T <= 10
0 <= N <= 10000
-10^4 <= LIST[i] <= 10^4
Where 'N' is the total number of nodes in the given linked list. ‘LIST[i]’ represents the node value of the node ‘i’.
Time limit: 1 sec
The basic idea is to break the linked list into two parts at the second last node position and then swap both halves.
The Steps are as follows: