문제2104--CROSSWORD

### 2104: CROSSWORD

실행시간 제한: 1 Sec  메모리사용 제한: 128 MB
제출: 19  통과: 8
[제출] [채점기록] [묻고답하기]

#### 문제 설명

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: Solve 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).

#### 입력 설명

The first line of the input will contain the number of test case, T. A test case consists six lines. 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.

Test cases are separated by a blank line.

#### 출력 설명

For each test case, print 0 if it is impossible to put together a 3 × 3 crossword using the given six words.

Otherwise, print 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.

Separate adjacent output of test cases by a blank line.

#### 입력 예시 Copy

2

ANA
ANA
DAR
DAR

AKO
CES
DOC
DON
ESI
KES

#### 출력 예시 Copy

DAR
ANA