Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official.
×

No tags yet

No tag edit access

The problem statement has recently been changed. View the changes.

×
time limit per test: 0.25 sec.

memory limit per test: 4096 KB

memory limit per test: 4096 KB

input: standard

output: standard

output: standard

Chessboard with length of a side N was broken into K pieces, each of them is presented as a connected area (in this case connected area means such subset of chessboard cells, that there is a path of rook from any of them to any other).

These pieces were scattered all over the table (maybe rotated by 90, 180 or 270 degrees). Your task is to reconstruct chessboard again (position of black and white cells doesn't matter).

It is guaranteed that it is possible to construct square with side N from pieces given to you using all pieces.

These pieces were scattered all over the table (maybe rotated by 90, 180 or 270 degrees). Your task is to reconstruct chessboard again (position of black and white cells doesn't matter).

It is guaranteed that it is possible to construct square with side N from pieces given to you using all pieces.

First line contains only one natural number N (1<=N<=5) - length of a side of the chessboard (in cells). Following 20 lines contain initial table description, each of these lines contains 20 characters. Empty place at the table is coded as "." character, and cells occupied by i-th piece of the chessboard are coded as i-th alphabet capital Latin letter.

You must output N lines of N characters - constructed square chessboard with side N. Areas presented by i-th piece must be filled i-th in order of alphabet capital Latin letter and correspond to source image of pieces (maybe rotated by 90, 180, or 270 degrees). If there are several solutions, print any one of them.

Input

3

....................

....................

....................

....................

........A...........

....................

...............C....

....................

..........B.........

....................

....................

....................

....................

............D.......

...........DDD......

............D.......

....................

....................

.................E..

....................

....................

....................

....................

....................

........A...........

....................

...............C....

....................

..........B.........

....................

....................

....................

....................

............D.......

...........DDD......

............D.......

....................

....................

.................E..

....................

Output

ADB

DDD

CDE

DDD

CDE

Author: | Dmitry Filippov |

Resource: | SPbETU Training. DEF's contest |

Date: | November, 2003 |

Codeforces (c) Copyright 2010-2021 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Sep/22/2021 11:33:45 (h2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|