SP4568 ANARC07C - Rotating Rings
Description
[English](/problems/ANARC07C/en/) [Vietnamese](/problems/ANARC07C/vn/)Any square grid can be viewed as one or more rings, one inside the other. For example, as shown in figure (a), a 5 x 5 grid is made of three rings, numbered 1,2 and 3 (from outside to inside.) A square grid of size N is said to be sorted, if it includes the values from 1 to N^2 in a row-major order, as shown in figure (b) for N = 4. We would like to determine if a given square grid can be sorted by only rotating its rings. For example, the grid in figure (c) can
be sorted by rotating the first ring two places counter-clockwise, and rotating the second ring one place in the clockwise direction.

Input
=====
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
Input Format
N/A
Output Format
N/A