<?xml version="1.0" encoding="Windows-1251"?>
<CATS version="1.0">
<Problem title="Advanced ASCII Cubes" lang="en" author="A. Klenin" tlimit="3" 
    inputFile="input.txt" outputFile="output.txt" stdChecker="strs">

<ProblemStatement>
  <p>The table surface is divided into <i>N</i> by <i>M</i> square cells.
  Some cubes are stacked one upon another over the cells, forming towers.
  For each cell the number of cubes stacked over it is given in the matrix A.</p>
  <p>Your program must output the view of the table in ASCII graphics,
  where each cube is represented as shown below:</p>
  <p>
  <table>
    <tr><td><pre>
  +---+
 /   /|      
+---+ |      
|   | + 
|   |/ 
+---+
</pre></td><td>(here the characters used are <code>'+'</code>, <code>'-'</code>, <code>'/'</code>, <code>'|'</code>,
  their ASCII codes are ASCII 43, 45, 47, 124)</td></tr>
  </table></p>
  The dot (ASCII 46) must be used as a background.

</ProblemStatement>

<InputFormat>
  Input file contains integers <i>N</i> <i>M</i>, followed by matrix <i>A</i>, row-by-row.
  The first row describes the cube tower furthest from the viewer, left to right, and the last row --
  nearest to the viewer. 
</InputFormat>

<OutputFormat>
  Output file must contain a string representation of the table view, with minimal number
  of lines required to show all cubes. Each line must contain a string of equal length,
  which is the minimal width required to show all cubes.
</OutputFormat>

<ProblemConstraints>
 1 &amp;le; <i>N</i>, <i>M</i>, <i>A<sub>ij</sub></i> &amp;le; 50
</ProblemConstraints>

<Sample rank="1">
  <SampleIn>3 4
1 1 1 1
1 2 1 1
1 1 1 1</SampleIn>
  <SampleOut>       
........+---+..........
......+/   /|-+---+---+
...../+---+ |/   /   /|
....+-|   | +---+---+ |
.../  |   |/   /   /| +
..+---+---+---+---+ |/.
./   /   /   /   /| +..
+---+---+---+---+ |/...
|   |   |   |   | +....
|   |   |   |   |/.....
+---+---+---+---+......
  </SampleOut>
</Sample>

<Sample rank="2">
  <SampleIn>3 5
2 2 1 2 2
2 2 1 1 2
3 2 1 2 2
</SampleIn>
  <SampleOut>
......+---+---+...+---+---+
..+---+  /   /|../   /   /|
./   /|-+---+ |.+---+---+ |
+---+ |/   /| +-|  /   /| +
|   | +---+ |/+---+---+ |/|
|   |/   /| +/   /   /| + |
+---+---+ |/+---+---+ |/| +
|   |   | +-|   |   | + |/.
|   |   |/  |   |   |/| +..
+---+---+---+---+---+ |/...
|   |   |   |   |   | +....
|   |   |   |   |   |/.....
+---+---+---+---+---+......
  </SampleOut>
</Sample>

<Solution name="sol" src="b.dpr" de_code="203"/>
<Generator name="genp" src="genp.dpr" de_code="203"/>
<Generator name="genr" src="genr.dpr" de_code="203"/>

<Test rank="1"><In src="01.tst"/><Out src="01.ans"/></Test>
<Test rank="2"><In src="02.tst"/><Out src="02.ans"/></Test>
<Test rank="3"><In src="03.tst"/><Out src="03.ans"/></Test>
<Test rank="4"><In src="04.tst"/><Out use="sol"/></Test>
<Test rank="5"><In src="05.tst"/><Out use="sol"/></Test>
<Test rank="6"><In src="06.tst"/><Out use="sol"/></Test>
<Test rank="7"><In src="07.tst"/><Out use="sol"/></Test>
<Test rank="8"><In src="08.tst"/><Out use="sol"/></Test>
<Test rank="9"><In src="09.tst"/><Out use="sol"/></Test>
<Test rank="10"><In use="genp" param="19"/><Out use="sol"/></Test>
<Test rank="11"><In use="genr" param="11"/><Out use="sol"/></Test>
<Test rank="12"><In use="genr" param="40"/><Out use="sol"/></Test>

</Problem>
</CATS>
