A 6×6 array contains digits from 0 to 9. You may apply the operations below any number of times, and you want to maximize the sum of all values in the array.
Each operation may be used without limit. Values always remain single digits: adding 1 to 9 gives 0, and subtracting 1 from 0 gives 9.
Consider the following array.
5 9 7 1 5 8
2 5 3 5 2 0
6 8 1 5 0 3
4 8 2 6 9 2
9 1 6 5 3 2
7 0 2 4 3 1
If 1 is added to the first row, the array becomes:
6 0 8 2 6 9
2 5 3 5 2 0
6 8 1 5 0 3
4 8 2 6 9 2
9 1 6 5 3 2
7 0 2 4 3 1
From there, if 1 is subtracted from the first column, the array becomes:
5 0 8 2 6 9
1 5 3 5 2 0
5 8 1 5 0 3
3 8 2 6 9 2
8 1 6 5 3 2
6 0 2 4 3 1
The array is given as 6 lines, each containing 6 integers. Every integer is between 0 and 9, inclusive.
Print the maximum possible sum of all array values on the first line.