We can create a hexagonal puzzle the size of

The goal of the puzzle is to put the pieces on the hexagon so that the following holds:
- Each piece is placed so it fully covers three shaded triangles.
- Each shaded triangle is covered by exactly one piece.
- Two pieces of the same colour do not touch along the side of a triangle (they may touch in a corner).
Determine if it is possible to solve the given puzzle, and, if it is, find one solution.
Input Specification
The first line of input contains the positive integer 0
denotes a shaded triangle, whereas
.
(dot) denotes a triangle that is not shaded. You can assume that at least one triangle will be shaded.
Output Specification
If the puzzle is impossible to solve, output in the first line nemoguce
(Croatian for impossible). Otherwise,
output
Constraints
Subtask | Score | Constraints |
---|---|---|
Sample Input 1
3
.000000
...000000
.....000000
.....0.....
...000...
.00000.
Sample Output 1
.111224
...332442
.....311122
.....1.....
...112...
.33322.
Sample Input 2
1
.0.
0.0
Sample Output 2
nemoguce
Sample Input 3
2
0000.
0000000
..00.0.
.0000
Sample Output 3
1222.
1133111
..31.2.
.1122
Comments