#C13499. Reverse Words in a Sentence

    ID: 43043 Type: Default 1000ms 256MiB

Reverse Words in a Sentence

Reverse Words in a Sentence

Given a sentence, reverse the order of its words. A word is defined as a maximal substring consisting of non-space characters. The words in the output should be separated by a single space without any leading or trailing spaces. In other words, if the input sentence is \(S = s_1 \ s_2 \ \cdots s_n\), where the \(s_i\) are the words, then the output should be \(s_n \ s_{n-1} \ \cdots \ s_1\).

For example, if the input is the sky is blue, the output should be blue is sky the.

inputFormat

The input consists of a single line containing the sentence \(S\). The sentence may be empty or contain multiple spaces between words, as well as leading or trailing spaces.

outputFormat

Output a single line containing the sentence with the words in reverse order. Each word must be separated by a single space, with no extra spaces at the beginning or end of the line.

## sample
the sky is blue
blue is sky the