Problem: We guessed a permutation consisting of integers. The permutation of length is the array of length where each element from to appears exactly once. This permutation is a secret for you.
For each position from to we chose some other index () and gave you the segment in sorted order (i.e. we rearranged the elements of this segment in a way that the elements of this segment are sorted). Thus, you are given exactly segments of the initial permutation but elements inside each segment are sorted. The segments are given to you in random order.
For example, if the secret permutation is then the possible given set of segments can be:
Your task is to find any suitable permutation (i.e. any permutation corresponding to the given input data). It is guaranteed that the input data corresponds to some permutation (i.e. such permutation exists).
You have to answer independent test cases.
Input Format: The first line of the input contains one integer () — the number of test cases. Then test cases follow.
The first line of the test case contains one integer () — the length of the permutation.
The next lines describe given segments.
The -th line contains the description of the -th segment. The line starts with the integer () — the length of the -th segment. Then integers follow. All integers in a line are distinct, sorted in ascending order, between and , inclusive.
It is guaranteed that the required exists for each test case.
It is also guaranteed that the sum of over all test cases does not exceed ().
Output Format: For each test case, print the answer: integers (, all should be distinct) — any suitable permutation (i.e. any permutation corresponding to the test case input).