#C14932. Reverse Words in Sentences

    ID: 44636 Type: Default 1000ms 256MiB

Reverse Words in Sentences

Reverse Words in Sentences

You are given n sentences. Your task is to reverse the order of words in each sentence.
Punctuation remains attached to the words they follow, and the original capitalization must be preserved.

Specifically, if a sentence is given as:

$$sentence = w_1 \; w_2 \; \dots \; w_m$$

Then the output should be:

$$output = w_m \; w_{m-1} \; \dots \; w_1$$

Read the input from stdin and output the results to stdout. Each output line corresponds to the reversed version of the input sentence.

inputFormat

The input starts with an integer n (1 ≤ n ≤ 100), which represents the number of sentences.
Each of the following n lines contains a single sentence. A sentence may include letters, punctuation, and whitespace.

outputFormat

For each input sentence, output a line where the words have been reversed.
The punctuation remains exactly attached to its respective word as in the input.

## sample
1
Hello, world!
world! Hello,

</p>