($w,$h,$z)=glob<>; $s=($w%3==2?2:1)*int(($w+2)/3); $t=($h%3==2?2:1)*int(($h+2)/3); if($z>$s*$t*9){ print -1; exit; } for$y(0..$h-1){ for$x(0..$w-1){ print $a[$y%3*3+$x%3]//=do{$y%3==2||($h-$y)%3==0||$x%3==2||($w-$x)%3==0 ? 0 : $z>9?($z-=9,9):($t=$z,$z=0,$t)}; } print$/; }