#!/usr/bin/perl

use strict;

open (TEAMS, "tmp.res");
my %teams;
while (<TEAMS>) {
    chomp;
    s/^\s+//;
    s/\s+$//;
    $teams{$_}=1;
}
close TEAMS;

my $name="";
while (<>) {
    chomp;
    s/^\s+//;
    s/\s+$//;
    if (/^From: (.*)$/) {
	$name=$1;
	next;
    }
    if (exists $teams{$_}) {
	s/\*\*\*\s+//;
	print "$name ($_)\n";
	next;
    }
}
	
