<?xml version="1.0" encoding="Windows-1251"?>
<CATS version="1.0">
<Problem title="Circle Drawing" lang="en" author="A. Klenin" tlimit="3" mlimit="4"
    inputFile="input.txt" outputFile="output.txt" stdChecker="longstrs">

<ProblemStatement>
<p>Graphics libraries usually implement drawing of graphics primitives, like lines, polygons and circles.
Your task is to write a program that draws circles.</p>
<p>Graphic canvas is represented as an array of <i>X<sub>size</sub></i> by <i>Y<sub>size</sub></i> pixels.
Each pixel have a color ranged from 0 to 9. Initially all pixels have color 0.
Pixels are thought of as small sqares with the side of length 1.
A circle with center (<i>x<sub>c</sub></i>, <i>y<sub>c</sub></i>) and radius <i>R</i>
is a set of pixels (<i>x</i>, <i>y</i>) satisfying the inequality
(<i>x</i> &amp;minus; <i>x<sub>c</sub></i>)<sup>2</sup> +
(<i>y</i> &amp;minus; <i>y<sub>c</sub></i>)<sup>2</sup> &amp;le; <i>R</i><sup>2</sup></p>
<p>To draw a circle, your program should set the color of all pixels in a set
defined above to the color of the circle. After drawing <i>N</i> given circles, the program 
should output the color of all pixels of the canvas.
</p>
</ProblemStatement>

<InputFormat>
Input file contains numbers <i>X<sub>size</sub></i> <i>Y<sub>size</sub></i> <i>N</i> followed
by <i>N</i> sets of numbers <i>x<sub>i</sub></i> <i>y<sub>i</sub></i> <i>R<sub>i</sub></i> <i>c<sub>i</sub></i>,
describing the coordinates of center, radius and color of <i>i</i>-th circle.
</InputFormat>

<OutputFormat>
Output file should contain <i>Y<sub>size</sub></i> lines of <i>X<sub>size</sub></i> characters each,
where <i>i</i>-th character of <i>j</i>-th line is a digit corresponding to color of the pixel (<i>i</i>, <i>j</i>).
</OutputFormat>

<ProblemConstraints>
1 &amp;le; <i>X<sub>size</sub></i>, <i>Y<sub>size</sub></i> &amp;le; 1000,
1 &amp;le; <i>N</i> &amp;le; 10000,
0 &amp;le; <i>x<sub>i</sub></i> &lt; <i>X<sub>size</sub></i>,
0 &amp;le; <i>y<sub>i</sub></i> &lt; <i>Y<sub>size</sub></i>,
1 &amp;le; <i>R<sub>i</sub></i> &amp;le; 200,
0 &amp;le; <i>c<sub>i</sub></i> &amp;le; 9.
</ProblemConstraints>

<Sample rank="1">
  <SampleIn>5 5 1
2 2 1 3</SampleIn>
  <SampleOut>00000
00300
03330
00300
00000</SampleOut>
</Sample>

<Sample rank="2">
  <SampleIn>4 3 2
2 2 2 5
0 1 1 9
</SampleIn>
  <SampleOut>9050
9955
9555</SampleOut>
</Sample>
<Solution name="sol" src="circles.dpr"/>
<TestRange from="1" to="5"><In src="t%0n"/><Out use="sol"/></TestRange>
<Generator name="g1" src="g1.dpr"/>
<Generator name="g2" src="g2.dpr"/>
<Test rank="6"><In use="g1" param="1000 a"/><Out use="sol"/></Test>
<Test rank="7"><In use="g1" param="2000 b"/><Out use="sol"/></Test>
<Test rank="8"><In use="g1" param="3000 c"/><Out use="sol"/></Test>
<Test rank="9"><In use="g2" param="997 10000 r"/><Out use="sol"/></Test>
<Test rank="10"><In use="g2" param="1000 10000 m"/><Out use="sol"/></Test>

</Problem>
</CATS>