

The attendees holding numbers from 1, 4, 3 are shown:

For the above example 1 -> 4 -> 3, 1 -> 3 -> 4 is the only correct answer, i.e nodes should be grouped sequentially. Hence, 3 -> 1 -> 4 is the wrong answer as we have to preserve the same order.
The first line of input contains an integer T, the number of test cases. Then each test case follows.
The first and the only line of every test case contains the elements of the singly linked list separated by a single space and terminated by -1.
Hence, -1 would never be a list element.
For every test case, print the bride’s side attendees followed by the groom’s side attendees.
The attendees/elements should be single-space separated, terminated by -1.
The output of each test case is printed in a separate line.
You don't need to print the output, it has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= N <= 5 * 10^4
0 <= data <= 10^4 and data != -1
Where 'N' denotes the number of elements in the Singly Linked List and 'data' represents the value of those elements.
Time Limit: 1 sec
As we have to arrange the nodes such that all the odd nodes should come before all the even nodes, we can move all the even valued nodes from their current positions to the end of the linked list.
The idea is to split the linked list into two: one containing all odd valued nodes and others containing all the even valued nodes. And finally, attach the even node linked list after the odd node linked list.