my %vals = map { $_ => 1 } ; print $_->[0] for grep { $vals{$_->[1]} } map { [ split / / ] } ;