A 3 \times 3 square is considered "Antimagic" if the sums of all rows, columns, and diagonals are distinct.
Help form an "Antimagic" square from the given nine numbers.
We ensure that there is at least one valid "Antimagic" square for the given input.
Input
A single line containing nine distinct integers from the interval [1, 1000].
Output
Print three rows of three numbers that form an "Antimagic" square.
Example
standard input | standard output |
---|
6 3 5 7 13 14 2 8 17
| 8 2 6
14 5 3
13 7 17
|
Note
For the first test case:
Row sums:
8 + 2 + 6 = 16
14 + 5 + 3 = 22
13 + 7 + 17 = 37
Column sums:
8 + 14 + 13 = 35
2 + 5 + 7 = 14
6 + 3 + 17 = 26
Diagonal sums:
8 + 5 + 17 = 30
6 + 5 + 13 = 24
All sums are distinct, so this is indeed an "Antimagic" square.