Once, a messenger of the sultan found a wall with this square filled with numbers:
| 6 | 1 | 8 |
|---|---|---|
| 7 | 5 | 3 |
| 2 | 9 | 4 |
Asked, Beremiz told the sultan that it was a “magic square” of order 3, that is, a square of size 3, where all the numbers between 1 and appear once, and where all the rows, all the columns and the two diagonals add up to the same number, 15 in the example.
Input consists of several cases, each with the order of a square, followed by rows, each with natural numbers between 1 and . Assume .
For every case, print “yes” if the given square is
magic, and “no” otherwise.
Input
3 6 1 8 7 5 3 2 9 4 3 6 1 8 7 5 9 2 3 4 3 1 6 8 5 7 3 9 2 4 1 1 2 1 2 3 4 4 4 5 16 9 14 11 2 7 1 8 13 12 15 10 3 6
Output
yes no no yes no yes