Merge sorted linked lists

Given 2 sorted linked lists , merge the two given sorted linked list and print the final Linked List.

Input Format
First Line contains T the number of test cases.
For each test case :
Line 1 : N1 the size of list 1
Line 2 : N1 elements for list 1
Line 3 : N2 the size of list 2
Line 4 : N2 elements for list 2

Constraints
1 <= T <= 1000
0<= N1, N2 <= 10^6
-10^7 <= Ai <= 10^7

Output Format
For each testcase , print the node data of merged linked list.

Sample Input

1

4

1 3 5 7

3

2 4 6

Sample Output

1 2 3 4 5 6 7

solution link: https://ide.codingblocks.com/s/293389

all the test cases show TLE

@1799sanya initialise head1 = NULL and head2 =NULL inside the while loop, so it gets initialised for each test case