# use strict; # use warnings; my %d; $d{$_} = 0 foreach 0 .. 9; <>; my $c = 0; while (<>) { chomp; my @x = split(/\s/); my @ds = @x[0 .. ($#x - 1)]; my $b = $x[-1]; if ($b eq 'YES') { $c++; $d{$_}++ foreach @ds; foreach (keys(%d)) { delete $d{$_} if $d{$_} < $c; } } else { delete $d{$_} foreach @ds; } last if scalar(keys(%d)) == 1; } print((keys(%d))[0], "\n");