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

t = int(raw_input())
for j in range(t):
    a = int(raw_input())
    c = []
    d = []
    for i in range(a):
        x = raw_input()
        c.append(x)
        
    for i in c:
        if i not in d:
            d.append(i)
    d.sort()
    for i in d:
        print i