Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register
Language:
Texture Tile
Time Limit: 2000MSMemory Limit: 65536K
Total Submissions: 1728Accepted: 406Special Judge

Description

Square raster image is represented by an array of N × N pixels. A texture tile 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.

Your program must, given an image, find its largest subimage which is a texture tile.

Input

Input file contains integer N followed by N2 numbers ci, j — pixel values.

Constraints

1 ≤ N ≤ 370, 0 ≤ ci, j ≤ 255.

Output

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.

Sample Input

Sample input 1
2
0 0
2 3
Sample input 2
4
1 0 0 0
1 2 5 2
1 0 0 0
4 4 4 4

Sample Output

Sample output 1
1 1 1
Sample output 2
1 2 3

Hint

Bold texts appearing in the sample sections are informative and do not form part of the actual data.

Source

Northeastern Europe 2005, Far-Eastern Subregion

[Submit]   [Go Back]   [Status]   [Discuss]

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator