324. The Text Formatting

Time limit per test: 0.25 second(s)
Memory limit: 65536 kilobytes
input: standard
output: standard

The Library of Berland has an ancient document with text composed of words, spaces and
  characters. A word is a sequence of Latin letters. The chief librarian asked you to format the text from the document by adding and removing spaces. There are special rules for using the
  character in the ancient documents which you need to obey.

  character can be used as:

If there is no
  character between words, the words should be delimited by a single space.

The resulting text should not have any other space characters.

The first line of the input contains N (1 ≤ N ≤ 100) — the number of lines with the text of the document to be formatted. Each of the following N lines contains the quoted text of the document to be formatted. The length of the text of each document is not less than 1 and not more than 100 characters.

For each document from the input write a separate line with the formatted text enclosed in quotes to the output. If it is impossible to correctly format the text, write the only word
  without quotes. If there are several solutions, choose any of them.

sample input
sample output
"This is sample -mample "
"No solution-"
"This is - - --possible test- -"
"This is sample-mample"
"This is -- -- possible test -- "

Online Contester Team © 2002 - 2010. All rights reserved.