Problem: More Unsullied army are joining Daenerys Stormborn of the House Targaryen, the First of Her Name, the Unburnt, Queen of Meereen, 
Queen of the Andals and the Rhoynar and the First Men, Khaleesi of the Great Grass Sea, Breaker of Chains, and Mother of Dragons.

We know Grey Worm is the Commander of Unsullied and needs his army organized. He has his unsullied army labelled with random numbers but in sorted order.

Since more army are joining, they come in number. N army come.
Each new Unsullied army have many soldiers each labelled with random numbers but in sorted order. 

Grey Worm has to now merge all army such that they still remain sorted.

Should he fail to do so Daenerys may punish him. He is worried. He needs your help!!

Input:
First line is T. Number of test cases.
For each test case:
First input number N. Number of new Unsullied army joining.
For N number of times, first input 'x' number of soldiers in each Unsullied army followed by 'x' random space separated sorted numbers(Labels of each soldier).

Output:
Print the labels of each soldier of new formed army in sorted order.

Constraints:

1 ≤ T ≤ 100

2 ≤ N ≤ 10

1 ≤ x ≤ 10000

1 ≤ 'label' ≤ 10^6

(Labels need not be unique.)

EXAMPLE:

Input

1

3

4

1 4 7 10

5

3 8 12 16 19

6

2 6 9 14 18 25

Output

1 2 3 4 6 7 8 9 10 12 14 16 18 19 25

SAMPLE INPUT
1
3
4
1 4 7 10
5
3 8 12 16 19
6
2 6 9 14 18 25

SAMPLE OUTPUT
1 2 3 4 6 7 8 9 10 12 14 16 18 19 25

Solution (in PYTHON):

Solution:
'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'
t=input()
while t>0:
	t-=1
	l=[]
	n=input()
	while n>0:
		n-=1
		p=input()
		x=[int(i) for i in raw_input().split()]
		for i in x:
			l.append(i)
	l.sort()
	print " ".join(str(i) for i in l)