SP1000 EQDIV - Equidivisions

Description

An equidivision of an n × n square array of cells is a partition of the n^2 cells in the array in exactly n sets, each one with n contiguous cells. Two cells are contiguous when they have a common side. A good equidivision is composed of contiguous regions. The figures show a good and a wrong equidivision for a 5×5 square: ![subir imagenes](https://cdn.luogu.com.cn/upload/vjudge_pic/SP1000/693424735b3b82a55d47c39c3448bb886293dcbf.png) Note that in the second example the cells labeled with 4 describe three non-contiguous regions and cells labeled with 5 describe two non-contiguous regions. You must write a program that evaluates if an equidivision of the cells in a square array is good or not.

Input Format

It is understood that a cell in an n×n square array is denoted by a pair (i, j), with 1

Output Format

For each test case good must be printed if the equidivision is good, in other case, wrong must be printed. The answers for the different cases must preserve the order of the input.