Codeforces Beta Round 44 (Div. 2)
C
Crossword
Codeforces
2000
原题
← BD →
翻译中…

Vasya trains to compose crossword puzzles. He can only compose crosswords of a very simplе type so far. All of them consist of exactly six words; the words can be read only from top to bottom vertically and from the left to the right horizontally. The words are arranged in the form of a rectangular "eight" or infinity sign, not necessarily symmetrical.

翻译中…

The top-left corner of the crossword coincides with the top-left corner of the rectangle. The same thing is correct for the right-bottom corners. The crossword can't degrade, i.e. it always has exactly four blank areas, two of which are surrounded by letters. Look into the output for the samples for clarification.

翻译中…

Help Vasya — compose a crossword of the described type using the given six words. It is allowed to use the words in any order.

翻译中…

Input

翻译中…

Six lines contain the given words. Every word consists of no more than 30 and no less than 3 uppercase Latin letters.

翻译中…

Output

翻译中…

If it is impossible to solve the problem, print Impossible. Otherwise, print the sought crossword. All the empty squares should be marked as dots.

翻译中…

If there can be several solutions to that problem, print the lexicographically minimum one. I.e. the solution where the first line is less than the first line of other solutions should be printed. If the two lines are equal, compare the second lines and so on. The lexicographical comparison of lines is realized by the < operator in the modern programming languages.

翻译中…

样例

Input #1
NOD
BAA
YARD
AIRWAY
NEWTON
BURN
Output #1
BAA...
U.I...
R.R...
NEWTON
..A..O
..YARD
InputCopy OutputCopy
Input #2
AAA
AAA
AAAAA
AAA
AAA
AAAAA
Output #2
AAA..
A.A..
AAAAA
..A.A
..AAA
InputCopy OutputCopy
Input #3
PTC
JYNYFDSGI
ZGPPC
IXEJNDOP
JJFS
SSXXQOFGJUZ
Output #3
JJFS....
Y..S....
N..X....
Y..X....
F..Q....
D..O....
S..F....
G..G....
IXEJNDOP
...U...T
...ZGPPC
InputCopy OutputCopy
题目信息
题号
47C
时间限制
2 s
内存限制
256 MB
标签
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。