Amit works at a data recovery company. Every day he is sent broken-down laptops from which he has to recover the hard disk data.
The data to recover is in the form of an array of distinct integers. However, the damaged laptops instead contain many incomplete copies of the original array. The original order of the integers is preserved in all the incomplete arrays, however, elements are missing in unknown positions.
Your job is to create a program for him to reconstruct the original array from these incomplete copies.
If multiple solutions exist, output the lexicographically smallest array. (See the example below)
First line contains N, the number of incomplete arrays provided.
2*N lines follow, the first for each contains K, the size of each array and next line contains the array of size K. This array denotes one of the N arrays which has missing values from the original array
Print the complete array in a single line.
0 <= N <= 1000
2 <= K <= 1000
0 <= Each integer <= 106
Any integer will not appear more than once in each array.
This problem was authored by Prinkesh Sharma.
There are 2 arrays with some missing values: [1,3] and [2,3,4].
Candidates for the original array are [1,2,3,4] and [2,1,3,4]. First one is lexicographically smaller than the second.