시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB0000.000%

문제

The Government, fearing that their secret plans to turn the University into a theme park might be discovered, have put the file through an electronic shredder which has chopped the text up into overlapping pieces. Write a program which can read a list of text fragments and use the overlaps to reassemble them so that we can reveal the Government’s plans.

입력

Input will consist of a series of problems. Each problem will consist of 1 to 20 lines of text terminated by a line containing a single #. Each line will contain between 1 and 72 characters. A word is deemed to be a sequence of 1 or more printable characters, and words will be separated by exactly one space. The sequence of problems will be terminated by a line containing a single #. The # character will not occur anywhere else in the file other than the specified places. Note that the chopping process might produce duplicate fragments.

출력

Correct output for each problem is any arrangement of the fragments such that each input fragment occurs in the result and adjacent fragments overlap. Any arrangement will do as long as adjacent pieces overlap exactly; you don't have to produce the longest or the shortest or any special kind. Since the input was obtained by chopping up a text, there is always at least one way of doing this.

For each problem output the recreated text as a sequence of one or more lines, where each line contains no more than 72 characters. Do not break a line other than in the space between words, in which case do not output the space. Separate successive problems by a blank line.

예제 입력 1

they chose Avant
from the regular text.
For headings, they
stands out nicely from
sans-serif font that stands
Avant Garde, a sans-serif
from the regular text.
#
a b r a
c a d a b r a
#
a b r a
c a d a b r a
r a c
#
#

예제 출력 1

For headings, they chose Avant Garde, a sans-serif font that
stands out nicely from the regular text.
c a d a b r a
c a d a b r a c