$first = <>;
chomp($first);
print $first, "\n";

$second = <>;
chomp($second);
print $second, "\n";

$third = <>;
chomp($third);
print $third, "\n";

@rowcol = split(" ", $second);
$col = $rowcol[0];
$row = $rowcol[1];

@image = ();
while(<>){  # get the pixels
  $_ =~ s/^\s+//;  # remove leading spaces
  @line = split(/\s+/, $_);
  push(@image, @line);
}

for($i=$row-1; $i>=0; $i--){
  for($j=0; $j<$col; $j++){
    $index = $i*$col + $j;
    print $image[$index], " ";
  }
  print "\n";
}
