You have been given ‘K’ different arrays/lists, which are sorted individually (in ascending order). You need to merge all the given arrays/list such that the output array/list should be sorted in ascending order.
Input Format :
The first line of input contains an integer T, the number of test cases. The first line of each test case contains an integer that denotes the value of K. The next 2*K lines of each test case follow: The first line contains an integer ‘N’ denoting the size of the array. The second line contains N space-separated integers.
Output Format :
The first and only line of output contains space-separated elements of the merged and sorted array, as described in the task.
Constraints :
1 <= T <= 5
1 <= K <= 5
1 <= N <= 20
-105 <= DATA <= 105
After merging the two given arrays/lists [3, 5, 9] and [ 1, 2, 3, 8], the output sorted array will be [1, 2, 3, 3, 5, 8, 9].