#C5991. Reverse Words in a String

    ID: 49701 Type: Default 1000ms 256MiB

Reverse Words in a String

Reverse Words in a String

Given a string consisting of words separated by spaces, your task is to reverse the order of the words. The input string may contain leading or trailing whitespaces and may contain multiple spaces between words. You should remove any extra spaces and print the reversed words in a single line separated by a single space.

Note: A word is defined as a sequence of non-space characters.

For example, if the input is Hello world this is a test , the output should be test a is this world Hello.

inputFormat

The input consists of a single line that contains the string to be processed. The string may include leading, trailing, or multiple spaces between words.

Input is provided via standard input (stdin).

outputFormat

Output a single line containing the words in reverse order with exactly one space between them. The output should be printed to standard output (stdout).

## sample
  Hello   world  this  is  a  test  
test a is this world Hello