BlueBook
Determine if a table of numbers containing rows and
columns is a
magic square.
An table of numbers
is a magic square if and only
the sum of the numbers along any row or column is constant. The
diagonals are not required to have the same sum.
Input Specification
The first line of input contains an integer
, the
number of test cases to follow.
Each test case starts with an integer
, which is
followed by
integers, each on its own line - the entries
of the table, in reading order. This means that the first
integers
represent the first row of the table, from left to right, the next
integers the second row likewise, and so on. There is a blank line
between each pair of adjacent cases.
Output Specification
For each test case, print yes
if it is a magic square, and no
if it
is not.
Sample Input
3
2
1
2
2
1
1
5
2
1
2
3
4
Sample Output
yes
yes
no
Comments