#C3408. Reverse Words in a String

    ID: 46832 Type: Default 1000ms 256MiB

Reverse Words in a String

Reverse Words in a String

You are given a string S consisting of words separated by one or more spaces. Your task is to output the string with the order of words reversed.

Note: A word is defined as a sequence of non-space characters. Extra spaces (including leading, trailing, or multiple spaces between words) should be handled so that the output contains words separated by a single space.

For example, if S is "Hello World", then the output should be "World Hello".

The reversal operation can be described by the following formula in \( \LaTeX \):

\( output = w_n \;w_{n-1} \;\dots\; w_1 \)

inputFormat

The input consists of a single line containing a string S.

outputFormat

Output a single line: the string S with the order of its words reversed. Words in the output should be separated by a single space.

## sample
Hello World
World Hello

</p>