Yoda's Speechwriter
Time limit2sMemory limit1024 MB
Reverse the word order in each period-terminated sentence of a line of lowercase words, keeping the periods and single spaces.
- Level
Easy2 of 10
- Topics
- String, Implementation
- Solved
- No attempts yet
Problem
Every important public figure has a speechwriter, a person who helps prepare a public speech and makes it more expressive and interesting. Grand Master Yoda, head of the Jedi Order, is no exception.
At first glance, Yoda's speechwriter may seem to have a harder job than others. Yoda's speech is peculiar, and studying it takes serious effort. In fact, the job is simpler. The speechwriter first writes a speech for an ordinary person, then reverses the word order in every sentence. The algorithm for turning ordinary speech into Yoda's speech is so uniform that the speechwriter decided to automate the process. They asked you to write a program that converts a speech written for an ordinary person into a speech for Yoda.
Input
The single line of the input file contains the speech written by the speechwriter. The speech consists of sentences separated from each other by periods (a period is placed right after the last word of a sentence).
Each sentence consists of words. A sentence contains at least one word. Adjacent words are separated by exactly one space. A word is a non-empty sequence of lowercase Latin letters. The line contains no extra spaces. It is guaranteed that the line is not empty and its length does not exceed characters.
Output
Print the converted speech for Yoda on one line, following the input format. The output must strictly follow the format described in the input.