($W,$H,$X)=glob<>; for$i(0..$H%3/2){ for$j(0..$W%3/2){ $X-=$_[$i+!($H%3)][$j+!($W%3)]=$X<9?$X:9 } } if($X){ print-1,$/ }else{ for$i(0..$H-1){ for$j(0..$W-1){ print$_[$i%3][$j%3]+0 } print$/ } }