A square raster image is represented by an N×N array of pixels. A texture tile is a square (sub)image whose first row is identical to its last row and whose first column is identical to its last column. This property is useful when covering the surface of a graphics object with repeated copies of a texture, because it lets adjacent copies join together "seamlessly".
Given an image, find the side length of the largest square subimage that is a texture tile.
The first token is the integer N. It is followed by N2 integers ci,j, the pixel values, given row by row (row 1 first, then row 2, and so on).
Print a single integer m: the side length of the largest texture tile contained in the image. (Since a single pixel is always a texture tile, m≥1 always holds.)