#! /usr/bin/perl
use strict;
use warnings;
use POSIX;

my $width = 599;
my $height = 599;
my $max = 7263081;

print "P5\n$width $height\n255\n";
while (<>) {
	/(\d+) (\d+) (\d+)/ or die;
	my ($i, $j, $z) = ($1, $2, $3);
	$z = log($z + 1.0) / log($max + 1.0);
	$z = pow($z, 20);
	print chr(int(255.0 * $z));
}
