Jenny is obsessed with
Jenny's friends have learned not to leave their Sudoku puzzles unattended when she's around. She will take any fully or partially completed Sudoku puzzle she finds and play a game of her own invention called "Lo Shudoku", in which she transforms the
Original Sudoku Board
Jenny's Transformation
Jenny's
"Lo Shudoku"
Square
When she plays Lo Shudoku, Jenny works on each of the nine
- First, she fills in all the blank spaces with the remaining integers from
to . Each number filled in counts as one move. - Once all the blanks are filled, she repeatedly swaps pairs of integers until she has a Magic Square. Each swap counts as one move.
When she has transformed each square in this way, she produces her Lo Shudoku square showing the number of moves she used to create each of the nine Magic Squares. In the example above, the Lo Shudoku square shows that the top left Magic Square took
Here is one way that Jenny could transform top right
In phase one she fills in the
The input contains ---
.
Sample Input
010596873
900413006
005872419
172040090
863259000
549060038
726984351
300100004
491635782
329847651
748561392
156392478
514726839
673985124
892413765
965138247
287654913
431279586
206004900
040900100
900800002
700045090
064389270
090120004
400003008
005008020
003500407
093006500
652830070
007500036
000060108
000908000
501040000
140002600
060097315
009600280
000050086
649300070
000640100
030021009
106000708
400980030
008072000
060003852
250060000
Sample Output
856
577
467
---
655
443
525
---
787
878
888
---
688
988
977
---
888
787
778
---
Educational Computing Organization of Ontario - statements, test data and other materials can be found at ecoocs.org
Comments