data-recovery-1

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)

Input Format
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

Output Format
Print the complete array in a single line.

Constraints
0 ≤ N ≤ 1000

2 ≤ K ≤ 1000

0 ≤ Each integer ≤ 10^6

Note
Any integer will not appear more than once in each array.

This problem was authored by Prinkesh Sharma.

SAMPLE INPUT
2
2
1 3
3
2 3 4

SAMPLE OUTPUT
1 2 3 4

Explanation

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.

Source: hackerearth | Difficulty: UNKNOWN_DIFFICULTY


Solutions: