403024: GYM100971 E Bisection

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

E. Bisectiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Pavel has developed the best game in the world — «Bisection». In this game the square grid of size n × n is given to a player. Some of the cells on the grid are selected and form a figure. A player should paint every cell of this figure in one of two colors so that the resulting figures of both colors would be equal. The figures are equal if one of them could be transformed into the other by translations, reflections relative to horizontal and vertical axes and turns by right angles.

Pavel has created an extra level for this game, but he can't understand if it has any solution. You have to find it out.

Input

The first line contains a single integer n (1 ≤ n ≤ 50) — the size of the grid.

Each of the next n lines contains n characters. The character is «.» if this cell doesn't belong to the figure, and «#» if it does.

It's guaranteed that the input contains positive even number of «#» characters.

Output

If there is no solution, output «NO» (without quotes).

Otherwise in the first line output «YES» (without quotes), and then output n lines of n characters describing the coloring of the figure. Characters «.» from the input shouldn't be touched, and characters «#» should be replaced with «A» or «B», depending on the color that should be used to paint this cell.

If there are many possible solutions, output any of them.

ExamplesInput
3

{.##}

{###}

{###}
Output
YES

.AA

BAB

BBA
Input
3

{###}

{.##}

{###}
Output
NO

加入题单

上一题 下一题 算法标签: