Public submissions
Source code of every submission to this problem in this contest will be visible for everyone since 2013-03-14 06:00:00.
Problem hidden
This problem was hidden by Editorial Board member probably because it has incorrect language version or invalid test data, or description of the problem is not clear.

BANDA - Before and After

A popular television game show requires contestants to identify a phrase, usually with some of the letters missing. Some of these phrases are formed from a combination of two phrases that are unrelated, except that the last word (or words) of the first phrase are the same as the first word (or words) of the second phrase.

For example, consider the phrases “the shallow end of the pool” and “the pool table.” The last two words of the first phrase (“the pool”) are the same as the first two words of the second phrase. These phrases could then be combined to yield the “before and after” phrase “the shallow end of the pool table.”

In this problem you are given a set of phrases and asked to find all possible “before and after” phrases that can be produced. For each such combination, you are to display the two phrases, one per line, with the common words aligned.

Input

The input data contains one line for each phrase, with a blank line following the last phrase. Each phrase will consist of words containing only lower-case alphabetic characters. Words are separated by one or more blanks, and blanks may precede or follow the phrase. No word will contain more than 12 letters, and no input line will contain more than 50 characters.

Output

Display three lines for each “before and after” phrase that can be produced from the phrases given in the input. On the first line, display the first phrase starting in column 1. On the second line, display the second phrase indented so the overlapping word (or words) are perfectly aligned under the matching words in the first phrase. The third line is blank. Each phrase should be displayed with exactly one blank between adjacent words.

The order in which the “before and after” phrases are displayed should correspond to the order in which the first phrase of the combination appears in the input data.

Sample Input

house  of  cards
     the pool table
  the white house
      the house limit
the  shallow  end  of  the pool

(Last line is blank.)

Expected Output

the white house
          house of cards
the shallow end of the pool
                   the pool table 

Added by:Fabio Avellaneda
Date:2013-02-25
Time limit:2s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:C C++ 4.3.2 CPP JAVA
Public source code since: 2013-03-14 06:00:00

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.