#!/usr/bin/perl

use v5.30;
use strict;

my %all;
my %below;
my %top;

while (<>) {
	my ($name, $num, $rest) = /^(\w+) \((\d+)\)(.*)/;
	$all{$name} = $num;
	next if !length $rest;
	for my $t ($rest =~ /(\w+)/g) {
		$below{$t} = $name;
		$top{$t} = 1;
	}
}

for my $node (keys %all) {
	say $node if !$top{$node};
}



