#K75192. Unique Word Summarizer
Unique Word Summarizer
Unique Word Summarizer
You are given a text consisting of words separated by spaces. Your task is to generate a summary of the text by keeping only the first occurrence of each word while preserving the original order.
For example, given the text:
this is a test this is only a test
the summary is:
this is a test only
Note: Words are defined as non-space sequences. No additional cleaning or punctuation handling is required.
Mathematically, if the text is represented as a sequence \(w_1, w_2, \ldots, w_n\), then the summary is the sequence \(w_{i_1}, w_{i_2}, \ldots, w_{i_k}\) where for any \(j < l\), \(i_j < i_l\) and for any word \(w\), it appears only once in the sequence.
inputFormat
The input is read from standard input and has the following format:
- An integer \(T\) representing the number of test cases.
- Then \(T\) lines follow, each containing a text.
outputFormat
For each test case, output a single line containing the summarized text (i.e., only the first occurrence of each word in the original order).
## sample2
this is a test this is only a test
Hello World Hello Hello World
this is a test only
Hello World
</p>