5
10
bb
bb
ab
aa
bb
bb
ba
aa
bb
ab
10
bb
ab
ba
ab
ba
ba
ab
ba
ba
ba
10
aa
ba
ba
ba
bb
ab
ab
aa
bb
bb
10
ab
ab
bb
bb
ab
ba
aa
ba
ab
aa
10
ba
bb
bb
bb
aa
ba
ba
ba
bb
bb
aa
ab
ba
bb
ab
ba
bb
aa
ab
ba
bb
aa
ab
ba
bb
aa
ba
bb

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

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
t= int(raw_input())
while(t>0):
	n = int(raw_input())
	l=[]
	while(n>0):
		l.append(raw_input())
		n=n-1
	l=set(l)
	l=list(l)
	l=sorted(l)
	for i in l:
		print i
	t=t-1