#C486. Reverse Words in Sentences

    ID: 48444 Type: Default 1000ms 256MiB

Reverse Words in Sentences

Reverse Words in Sentences

You are given a paragraph consisting of one or more sentences. Each sentence is terminated by a period ('.') and may be followed by a space. Your task is to reverse the order of words in each sentence while keeping the original sentence order intact. Additionally, every sentence in the output must start with an uppercase letter and the remaining letters should be in lowercase.

For example, if a sentence in the paragraph is given by

( S = w_1, w_2, \dots,, w_n ),

then its output should be:

( S' = \text{capitalize}(w_n, \dots,, w_1) ),

where capitalize converts the entire sentence to lowercase and then capitalizes only the first letter.

Input is provided from standard input (stdin) and output should be printed to standard output (stdout).

inputFormat

The input consists of a single line which contains the paragraph. The paragraph is a non-empty string composed of one or more sentences. Each sentence ends with a period ('.') and sentences are separated by a dot followed by a space.

outputFormat

Output the transformed paragraph where the words in each sentence are reversed and each sentence is formatted such that only the first letter is uppercase and the rest are lowercase. The sentences should be separated by a dot and a space, and the final sentence should end with a period.

## sample
Hello world. Today is a great day.
World hello. Day great a is today.