($h,$w)=glob<>; $r=<>; print 999; for(<>=~/ \d+/g){ print$",++$x+$h-$_; } print$/; for($r=~/ \d+/g){ print++$y+$w-$_; for(1..$w-1){ print$",$_+$y; } print$/; }