#K75802. Reverse Words in a Sentence

    ID: 34500 Type: Default 1000ms 256MiB

Reverse Words in a Sentence

Reverse Words in a Sentence

You are given a sentence as a string. Your task is to reverse the order of its words. A word is defined as a sequence of non-space characters. For example, if the input is "Hello world!", the output should be "world! Hello".

If the sentence is empty, output an empty string.

The reversal follows this formula: if the sentence is represented as \( s = w_1 \; w_2 \; \ldots \; w_n \), then the output should be \( s' = w_n \; w_{n-1} \; \ldots \; w_1 \).

inputFormat

The input consists of a single line containing a sentence. The sentence may contain letters, punctuation, and symbols. Words are separated by whitespace.

outputFormat

Output a single line containing the words in reverse order. There should be a single space between words and no extra spaces at the beginning or end of the line.

## sample
Hello world!
world! Hello