my $n=get.Int; my Set $se=(0..9).Set; for ^$n { my @parts=get.words; my $r=@parts[*-1]; my Set $a=@parts[0..*-2].map(*.Int).Set; if $r eq "YES" { $se = $se ∩ $a; } else{ $se = $se (-) $a; } } +$se==1 or die "Assertion failed: Invalid input encountered"; say $se.keys[0];