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

문제

아래와 같은 가로 세로 퍼즐을 풀어보자.

가로줄

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

세로줄

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

6개의 단어가 주어졌을 때, 이를 가지고 가로 세로 퍼즐을 만드는 프로그램을 작성하시오. 단어 3개는 가로줄, 3개는 세로줄로 배치해야한다.

입력

6개의 줄에 알파벳 대문자로 이루어진 단어가 주어진다. 이 단어는 사전순으로 정렬되어 있다.

출력

6개 단어를 3*3 가로 세로 퍼즐에 놓을 수 없다면 0을 출력한다. 그렇지 않다면, 3개 줄에 퍼즐을 출력한다. 만약 가능한 답이 여러개라면 사전순으로 앞서는 것을 출력한다. 사전순으로 비교를 할 때는, 모두 한 줄로 이어붙인 9개의 단어를 생각하면 된다.

예제 입력 1

ANA
ANA
DAR
DAR
RAD
RAD

예제 출력 1

DAR
ANA
RAD

예제 입력 2

EVO
HEP
HIR
IVA
PAD
ROD

예제 출력 2

HEP
IVA
ROD

예제 입력 3

AKO
CES
DOC
DON
ESI
KES

예제 출력 3

0
W3sicHJvYmxlbV9pZCI6IjI3ODQiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWFjMDBcdWI4NWMgXHVjMTM4XHViODVjIFx1ZDM3Y1x1Yzk5MCIsImRlc2NyaXB0aW9uIjoiPHA+XHVjNTQ0XHViNzk4XHVjNjQwIFx1YWMxOVx1Yzc0MCBcdWFjMDBcdWI4NWMgXHVjMTM4XHViODVjIFx1ZDM3Y1x1Yzk5MFx1Yzc0NCBcdWQ0ODBcdWM1YjRcdWJjZjRcdWM3OTAuPFwvcD5cclxuXHJcbjxwIHN0eWxlPVwidGV4dC1hbGlnbjogY2VudGVyO1wiPjxpbWcgYWx0PVwiXCIgc3JjPVwiaHR0cHM6XC9cL3VwbG9hZC5hY21pY3BjLm5ldFwvNDViZGY3NWItMDI4MC00YWU1LTk0YjM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