A crossword can be stored as an $m \times n$ matrix of zeros and ones. A zero is a white square and a one is a black square. Some white squares are numbered; each number labels the clue for a word to be written across or down.
A white square is numbered when either:
Squares are numbered from left to right, from the top row to the bottom row, starting at 1.
From the matrix a diagram is drawn. Each square becomes a box 4 characters tall and 6 characters wide, and neighbouring boxes share their common border row or column (so the whole diagram is $3m + 1$ rows tall and $5n + 1$ columns wide). A black square is drawn as:
++++++
++++++
++++++
++++++
A white square is drawn as one of the following (numbered on the left, not numbered on the right):
++++++ ++++++
+nnn + + +
+ + + +
++++++ ++++++
where nnn is the square's number written with leading zeros as three digits.
Every other character inside a box is a space. A black square that lies on the border of the grid — together with every black square joined to it through other black squares — is erased from the diagram and drawn as blanks. Black squares fully enclosed by white squares stay black. Use spaces only where needed, and print no trailing spaces at the end of any line.
The input has several blocks, one per crossword. Each block starts with a line holding two integers $m < 25$ and $n < 25$ separated by one space. The next $m$ lines each hold $n$ integers (0 or 1) separated by single spaces. The input ends with a block whose first line is 0 0; this terminating block has no grid and is not drawn.
For every block except the terminating one, print the corresponding diagram, with no trailing spaces at the end of any line. Consecutive diagrams are separated by two blank lines.