Page not loading? Try clicking here.
Placeholder

#1535

List of unique words 1s 32MB

Problems

Write a program that maintains a list of words from input strings.

  • For each input string, split it into words by spaces.

  • If a word is not already in the list, add it to the end of the list.

  • If a word is already in the list, do not add it again.

  • Initially, the list is empty.

  • The order of words in the list must reflect the order in which they were first added.

  • Uppercase and lowercase letters are distinct.

The program continues to accept input strings until the string "END" is entered, which ends the program.


Input

Up to 10 input strings, each of length at most 100 characters.

Words in the input are separated by spaces.

Input strings may contain letters, digits, or other characters.

The program ends when the input string is "END".


Output

After each input string (except "END"), print the current word list on a single line, with words separated by spaces.


Example

I am a boy

I am a girl
END
I am a boy

I am a boy girl


Source

JUNGOL - comkiwer

You must sign in to write code.