# make input into a huge string
$lines = join '', <>;

# change newlines to spaces
$lines =~ s/\n/ /g;

# strip leading whitespace
$lines =~ s/^\s+//;

# break the line into fields with whitespace as the delimiter
@pixels = split(/\s+/, $lines);

# print the first four fields verbatim
foreach $i (1..4) {
  print shift(@pixels) . "\n";
}

# negate the remaining fields by removing them from the array one
# at a time
while (@pixels > 0) {
  print 255 - shift(@pixels);
  print "\n";
}

