#P1798B. Three Sevens
Three Sevens
Description
Lottery "Three Sevens" was held for days. On day , people with the numbers participated in the lottery.
It is known that in each of the days, only one winner was selected from the lottery participants. The lottery winner on day was not allowed to participate in the lottery in the days from to .
Unfortunately, the information about the lottery winners has been lost. You need to find any possible list of lottery winners on days from to or determine that no solution exists.
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains a single integer () — the number of days in which the lottery was held.
Next, for each from to , follows a two-line block of data.
The first line of each block contains a single integer () — the number of lottery participants on day .
The second line of the block contains integers () — lottery participants on day . It is guaranteed that all the numbers are pairwise distinct.
It is guaranteed that the sum of over all blocks of all test cases does not exceed .
For each test case, if there is no solution, print a single integer .
Otherwise, print integers () — lottery winners on days from to . If there are multiple solutions, print any of them.
Input
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains a single integer () — the number of days in which the lottery was held.
Next, for each from to , follows a two-line block of data.
The first line of each block contains a single integer () — the number of lottery participants on day .
The second line of the block contains integers () — lottery participants on day . It is guaranteed that all the numbers are pairwise distinct.
It is guaranteed that the sum of over all blocks of all test cases does not exceed .
Output
For each test case, if there is no solution, print a single integer .
Otherwise, print integers () — lottery winners on days from to . If there are multiple solutions, print any of them.
Note
In the first test case, one of the answers is since the participant with the number participated on day , but did not participate on days and ; the participant with the number participated on day , but did not participate on day ; and the participant with the number participated on day . Note that this is not the only possible answer, for example, is also a correct answer.
In the second test case, both lottery participants participated on both days, so any possible lottery winner on the day must have participated on the day , which is not allowed. Thus, there is no correct answer.
In the third test case, only one participant participated on days , , , and on day there is only one participant who did not participate in the lottery on days — participant , which means is the only correct answer to this test case.