#C668. Unique Recommendations

    ID: 50466 Type: Default 1000ms 256MiB

Unique Recommendations

Unique Recommendations

You are given a list of recommended items which may contain duplicates. Your task is to remove duplicate entries while preserving the order of their first appearance. The input consists of multiple test cases. For each test case, you will be given a number of items followed by the list of items. Your program should output the de-duplicated list for each test case, with items separated by a single space.

The challenge tests your ability to handle array processing and maintaining order while filtering duplicates. Mathematically, for a list A=[a1,a2,,an]A = [a_1, a_2, \dots, a_n], the desired output is a list BB such that if aia_i appears earlier than aja_j in AA and ai=aja_i = a_j, only the first occurrence is kept in BB.

inputFormat

The input is read from standard input (stdin) and has the following format:\n\nThe first line contains an integer TT representing the number of test cases.\nFor each test case, the first line contains an integer nn representing the number of recommended items. The following line contains nn space-separated strings.

outputFormat

For each test case, output a single line on standard output (stdout) containing the unique recommended items separated by a single space, in the order of their first occurrence.## sample

3
5
apple banana apple orange banana
4
toy truck game toy
6
chair table chair lamp table chair
apple banana orange

toy truck game chair table lamp

</p>