use strict;

print "<html><head></head><body><table border=1>";

my ($alg_file,$a_file,$b_file)=@ARGV;

my %a;
my %b;

open (A, $a_file);
while (<A>) {
    if (/^\[\d+-(\d+)/) {
	$a{$1}=$_;
    }
}

open (B, $b_file);
while (<B>) {
    if (/^\[\d+-(\d+)/) {
	$b{$1}=$_;
    }
}

if ($alg_file eq "NONE") {

	foreach my $aa (sort {$a <=> $b} keys %a) {
	    print "<tr><td>";
	    print $a{$aa}, "<br>";
	    print "</td><td>";
	    print $b{$aa}, "<br>";
	    print "<td></tr>";

	}

}
else {
	open (ALG, $alg_file);
	while (<ALG>) {

	    print "<tr><td>";

	    my ($as,$bs) = split;

	    my @a=split(/,/,$as);
	    foreach my $a (@a) {
		print $a{$a}, "<br>";
	    }

	    print "</td><td>";

	    my @b=split(/,/,$bs);
	    foreach my $b (@b) {
		print $b{$b}, "<br>";
	    }

	    print "<td></tr>";

	}
}

print "</table></body></html>";
