


The first line of input contains a single integer T, representing the number of test cases or queries to be run.
Then the T test cases follow.
The first line of each test case contains the elements of the first singly linked list separated by a single space and terminated by -1. Hence, -1 would never be a list element.
The second line of each test case contains the elements of the second singly linked list separated by a single space and terminated by -1. Hence, -1 would never be a list element.
For each test case, print the multiplied linked list. The elements of the multiplied list should be single-space separated, terminated by -1.
The output of each test case is printed in a separate line.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= N, M <= 100
0 <= data <= 9
Where N and M are the number of nodes in the two linked lists.
Time Limit: 1 sec
The idea is to use the simple method of multiplying two numbers. We multiply two numbers starting from their least significant digit and moving towards the most significant digit. So we need to access the nodes of linked lists from last to first. First step would be to reverse both the linked lists. Then multiply both the linked lists starting from their heads and then reverse the resulting multiplied list and return its head.
Algorithm :