<?xml version="1.0" encoding="Windows-1251"?>
<CATS version="1.2">
<Problem title="Texture Tile" lang="en"
  author="A. Klenin, T. Chistyakov" tlimit="2" mlimit="256" inputFile="input.txt" outputFile="output.txt">

<ProblemStatement>
 <p>Square raster image is represented by an array of $N \times N$ pixels.
 A <i>texture tile</i> is a square image in which the first row is equal to the last one,
 and the first column is equal to the last one. This property is valuable when covering
 the surface of graphics object with repeating copies of texture, because it
 allows "seamless" transitions between tiles.
 </p><p>
 Your program must, given an image, find its largest subimage which is a texture tile.</p>
</ProblemStatement>

<ProblemConstraints>
 $1 \le N \le 370$, $0 \le c_{i, j} \le 255$.
</ProblemConstraints>

<InputFormat>
 Input file contains integer $N$ followed by $N^2$ numbers $c_{i, j}$ -- pixel values.
</InputFormat>

<OutputFormat>
 Output file must contain numbers $p q m$ -- coordinates of top left corner and size of the
 largest texture tile. If several solutions exist, output any of them.
</OutputFormat>

<Sample rank="1">
  <SampleIn>2
0 0
2 3</SampleIn>
  <SampleOut>1 1 1</SampleOut>
</Sample>
<Sample rank="2">
  <SampleIn>4
1 0 0 0
1 2 5 2
1 0 0 0
4 4 4 4</SampleIn>
  <SampleOut>1 2 3</SampleOut>
</Sample>

<Checker src="check.dpr" style="testlib" />
<Generator name="genRand" src="genRand.dpr" outputFile="*STDOUT" />
<Generator name="n4killer" src="g1.dpr" outputFile="*STDOUT" />

<Solution name="n4" src="texture_n4.dpr" />
<Solution name="n3" src="texture_tim.dpr" />
<Solution name="n4fast" src="texture_n4_m.dpr" />

<TestRange from="1" to="3"><In src="%0n" /><Out use="n3"/></TestRange>
<Test rank="4"><In use="genRand" param="100 15 3331" /><Out use="n3"/></Test>
<Test rank="5"><In use="genRand" param="150 40 3332" /><Out use="n3"/></Test>
<Test rank="6"><In use="genRand" param="250 256 3333" /><Out use="n3"/></Test>

<Test rank="7"><In use="genRand" param="100 2 3334" /><Out use="n3"/></Test>
<Test rank="8"><In use="genRand" param="370 2 3335" /><Out use="n3"/></Test>
<Test rank="9"><In use="genRand" param="370 1 3336" /><Out use="n3"/></Test>
<Test rank="10"><In use="genRand" param="250 256 3337" /><Out use="n3"/></Test>
<Test rank="11"><In use="genRand" param="250 256 3338" /><Out use="n3"/></Test>
<Test rank="12"><In use="genRand" param="370 100 3339" /><Out use="n3"/></Test>
<Test rank="13"><In use="genRand" param="370 150 3340" /><Out use="n3"/></Test>

<Test rank="14"><In use="n4killer" param="250 1" /><Out use="n3"/></Test>
<Test rank="15"><In use="n4killer" param="250 2" /><Out use="n3"/></Test>
<Test rank="16"><In use="n4killer" param="250 3" /><Out use="n3"/></Test>
<Test rank="17"><In use="n4killer" param="250 4" /><Out use="n3"/></Test>

<Test rank="18"><In use="n4killer" param="300 1" /><Out use="n3"/></Test>
<Test rank="19"><In use="n4killer" param="300 2" /><Out use="n3"/></Test>
<Test rank="20"><In use="n4killer" param="300 3" /><Out use="n3"/></Test>
<Test rank="21"><In use="n4killer" param="300 4" /><Out use="n3"/></Test>

<Test rank="22"><In use="n4killer" param="370 1" /><Out use="n3"/></Test>
<Test rank="23"><In use="n4killer" param="370 2" /><Out use="n3"/></Test>
<Test rank="24"><In use="n4killer" param="370 3" /><Out use="n3"/></Test>
<Test rank="25"><In use="n4killer" param="370 4" /><Out use="n3"/></Test>

</Problem>
</CATS>
