시간 제한
메모리 제한

Your program will be tested on one or more test cases. The first input line of a test case is an integer N which is the size of the grid. N input lines will follow, each line made of N integer values specifying the values in the grid in a row-major order. Note than 0 < N ≤ 1, 000 and grid values are natural numbers less than or equal to 1,000,000.
The end of the test cases is identified with a dummy test case with N = 0.
For each test case, output the result on a single line using the following format:
k.␣result
Where k is the test case number (starting at 1,) ␣ is a single space, and result rings.(c|cpp|java) rings.in is "YES" or "NO" (without the double quotes.)