#K83192. Remove Duplicate Words

    ID: 36143 Type: Default 1000ms 256MiB

Remove Duplicate Words

Remove Duplicate Words

Given a list of strings, each string containing words separated by spaces, your task is to remove duplicate words from each string while preserving the order of their first occurrence. For example, given the input "apple banana apple orange", the output should be "apple banana orange".

In this problem, you are required to process multiple test cases. The input begins with an integer \(n\) representing the number of strings. Then, \(n\) lines follow, each containing a string. For each string, remove duplicate words while preserving the order of appearance and print the resulting string on a new line.

inputFormat

The input is read from standard input (stdin). It starts with a single integer \(n\) indicating the number of test cases. The following \(n\) lines each contain a non-empty string consisting of words separated by spaces.

outputFormat

For each test case, output the string with duplicate words removed, preserving the order of their first appearance. Each result should be printed on a new line to the standard output (stdout).

## sample
1
apple banana apple orange
apple banana orange

</p>