73 - ZOJ Monthly, December 2008 - G
watashi's mm is so pretty as well as serious. All her English text is written under these following rules:
However, watashi is a very naughty boy. One day when his mm goes shopping and leaves her text at home, watashi begins his mischief. Firstly, the first letter of a sentence may be changed into lowercase. Then he adds some spaces between words or between word and punctuation. After that he deletes some spaces between word and punctuation. At last, he adds some spaces. When he divides a word by spaces, a hyphen ('-') will be appended to the first part. A word will never be divided more than once. Note that, after his mischief there may be more than 80 characters in a single line.
Imaginably, watashi's mm is so angry that she orders watashi to remake the text so that it will obey those original rules (all rules that are mentioned above). Unfortunately, watashi is known as a completely destroyer. It's almost impossible for him to do something constructive. To forbid parting from his mm, watashi turns to you for help. How poor watashi is! Given the text watashi makes, please write a program to output the original form of the text.
The first line of input is the number of test cases T, then T test cases follow.
Each test case consists of only one paragraph, which is made up of characters (letters, punctuations or spaces). Each test case is ended by a line of "###".
For each test case, output the original form of the text. Print a blank line between cases.
1 er ? watashi mm is a beautiful girl ! all her Eng- lish text is written under these following rules.there should be no more than eighty characters in a sin- gle line and please apply the rules of automatically starting a new line. ###
Er? Watashi mm is a beautiful girl! All her English text is written under these following rules. There should be no more than eighty characters in a single line and please apply the rules of automatically starting a new line.
Author: MO, Luyi
Source: ZOJ Monthly, December 2008