#!/usr/local/bin/perl

$done = $total1 = $total2 = 0;
while (1) {
        $num1 = <STDIN>;
        last if ($num1 eq "");
        chop ($num1);
        $num2 = <STDIN>;
        $done = 1 if ($num2 eq "");
        chop ($num2);
        $~ = "LINE";
        write;
        $total1 += $num1;
        $total2 += $num2;
}
$~ = "TOTAL";
write;
$~ = "GRAND_TOTAL";
write;

format LINE =
                    @####.##   @####.##
                    $num1      $num2
.
format TOTAL =
   column totals:  @#####.##  @#####.##
                    $total1    $total2
.
format GRAND_TOTAL =
grand total:                  @#####.##
                    $total1 + $total2
.
