This problem deals with Magic Squares that aren't quite magic. Recall that a magic square is a two-dimensional array of numbers such that the sum of each of the elements in each row and in each column are the same. (In some magic squares, the diagonals also sum to the same value as the rows and columns. For this problem, our magic squares do not necesarily share this property.) For example, this 3x3 array
| 2 | 9 | 4 |
| 6 | 1 | 8 |
| 7 | 5 | 3 |
Note: All values (input and output) are integers right-justified in seven-column fields.
For this problem, you are to read a series of 10x10 arrays of integers. The first line of the input contains the number of arrays to be processed. Each array is encoded in 10 input lines, one line per row (hence, each line contains 10 integers).
Each square you read is "not quite magic". That is, the sums do not all equal the same number. Three elements of each square have been modified. One element had the number 1 added to it, another had the number 2 added to it, and a third had the number 4 added to it. Your problem is to find these incorrect elements.
Your program should have five lines for each square. The first line is the magic square value: the correct sum of any row or column. The next three lines contain the row and column number of each of the three incorrect entries in order (off by 1 entry, off by 2 entry, then off by 4 entry). The last of the five lines is blank.
2
5 252 595 103 45 6 228 476 140 152
271 82 51 592 5 107 105 137 565 86
34 465 180 151 173 331 492 111 20 46
669 162 104 11 55 543 159 198 81 19
23 41 75 143 723 13 17 78 195 697
169 133 535 57 106 30 68 719 93 91
124 35 156 620 65 282 157 60 486 16
261 618 36 74 12 28 614 98 67 193
396 189 185 87 144 458 122 77 179 164
50 26 88 163 673 203 39 47 175 537
4 252 596 103 45 6 228 476 140 152
271 84 51 592 5 107 105 137 565 86
38 463 180 151 173 331 492 111 20 46
669 162 104 11 55 543 159 198 81 19
23 41 71 143 723 13 17 78 195 697
169 133 535 57 106 30 68 719 93 91
124 35 156 620 65 282 157 60 486 16
261 618 36 74 12 28 614 98 67 193
396 189 185 87 144 458 122 77 179 164
50 26 88 163 673 203 39 47 175 537
2001 1 1 3 2 5 3 2001 1 3 2 2 3 1