Problem list
Log in
#coci00240 · COCI 2012/2013 Contest 2

Krizaljka

Silver II 1.0 s 32 MB

Do you like to solve crosswords? If you do, you probably know the traditional lead-in for beginners – small 3 by 3 crosswords, like the following^{1}:

1 2 3

2

3

Horizontal:

  1. device used to cool a PC
  2. solid water
  3. to obtain

Vertical:

  1. small, soft, sweet fruit
  2. strong playing card
  3. fisherman's tool

1Solve a crossword like this one! Not gonna happen? Fine, then at least put it together given six words that appear in it (three as horizontal and three as vertical).

Input

Each of the six lines of input contains a word consisting of three uppercase English letters. The words are given in a lexicographically sorted order.

Output

If it is impossible to put together a 3 by 3 crossword using the given six words, output 0. Otherwise, output the crossword in three lines. If there is more than one possible solution, output the one that is first in lexicographic order, where, for sorting purposes, the crossword is viewed as a nine-letter word obtained by concatenating its rows.

Example 1

Input
ANA
ANA
DAR
DAR
RAD
RAD
Output
DAR
ANA
RAD

Example 2

Input
EVO
HEP
HIR
IVA
PAD
ROD
Output
HEP
IVA
ROD

Example 3

Input
AKO
CES
DOC
DON
ESI
KES
Output
0


1 adapted from http://www.goobix.com/crosswords/0303/
Source
COCI 2012/2013 Contest 2
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code