5136: Rune Master's Magic Matrix

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:2 解决:2

题目描述

Rune Master is a magic knight came from Elrios land(艾里奥斯大陆) and the power of rune(符文) make him stronger.
For more powerful rune, he started to travel the world.
One day in a valley(山谷), he fond a shining stone with a lot of numbers(just like the numbers in the input).It seems that there must have excellent rune in it.
So he came to visit a  alchemist friend called Allen to solve the mystery of the shining stone.
Allen said to Rune Master as follows. 
The numbers is a kind of matrix called magic matrix(魔方阵). All rows and columns of the magic matrix have the save sum.  But there is a part of numbers disappeared.
I will write down it in a simple way. If you can complete it, then you will get a more powerful rune.
Besides, according to my research, the incomplete magic matrix won't have the sub-matrix(子矩阵) which all number in it was disappeared.


Rune Master come to you ask for help.If can assist the Rune Master solve the problem the you will get a new skill called Luna Blade.



输入

The input is just a matrix with 5 rows and 5 columns.Each element of it should be large than 1 and less than 100.
But there are some positions the number is disappeared and the number of lost position are greater than or equal to 1 but less than or equal to 4.
For convince, those lost position is filled with -1.
And there won't have the submatrix as follow:
 -1  -1
 -1  -1
There is sample in the sample input. 

输出

The magic matrix completed.


样例输入 复制

 17  24   1   8  15
 23   5   7  -1  16
  4   6  13  20  22
 10  -1  19  21   3
 11  18  25   2   9

样例输出 复制

 17  24   1   8  15
 23   5   7  14  16
  4   6  13  20  22
 10  12  19  21   3
 11  18  25   2   9

提示

Each number is in the format of %3d.