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

tc = int(raw_input())
while(tc > 0):
	tc -= 1 
	invite_list = []
	N = int(raw_input())
	while (N > 0):
		N -= 1
		name = raw_input()
		invite_list.append(name)
	
	invite_lst = list(set(invite_list))
	list.sort(invite_lst)
	for name in invite_lst:
		print name