#C185. Extract Distinct Words

    ID: 45100 Type: Default 1000ms 256MiB

Extract Distinct Words

Extract Distinct Words

You are given a string which may contain letters, numbers, and various punctuation marks.

Your task is to extract all distinct words from the input. A word is defined as a contiguous sequence of alphabetic characters (both uppercase and lowercase). The extraction is case-insensitive, i.e. "Apple" and "apple" are considered to be the same word.

The output should be the list of distinct words in lexicographical order, separated by a single space. If there are no words, output an empty line.

In formal terms, if the input string is
\( S \), then find all strings \( w_i \) such that each \( w_i \) consists solely of alphabetic characters (A–Z and a–z). Convert them to lowercase, remove duplicates, sort them in lexicographical order, and output them separated by spaces.

inputFormat

The input is provided via stdin as a single text. It may contain letters, numbers, spaces, and punctuation marks.

outputFormat

Print the distinct words extracted according to the problem's criteria. The words should be printed on one line separated by a single space using stdout. If no word is found, print an empty line.

## sample
Hello, world! Hello.
hello world