#K9781. Combine Text Chunks

    ID: 39106 Type: Default 1000ms 256MiB

Combine Text Chunks

Combine Text Chunks

In this problem, you are given several chunks of text. Each chunk consists of a sequence of strings. Your task is to combine the strings in each chunk into a unified document, while eliminating duplicate lines while preserving their original order.

For each test case, you will be given an integer ( n ) that represents the number of lines in the text chunk, followed by ( n ) strings. You need to output the unique strings in the order in which they first appear, separated by a single space. If a test case has no lines, output nothing for that test case.

inputFormat

The first line of input contains an integer ( T ) (( T \ge 0 )), the number of test cases. For each test case, the first line contains an integer ( n ) (the number of lines in the chunk). Each of the following ( n ) lines contains a non-empty string. All strings consist of printable characters without extra spaces.

outputFormat

For each test case, print a single line with the unique strings from the chunk separated by a single space, preserving the order of their first appearance. If a test case has no lines, print an empty line.## sample

2
3
apple
banana
apple
2
hello
world
apple banana

hello world

</p>