#!perl -lan
@a{@F}=($l,$r)=@F;$h{$l}{$r}=$l ne$r;END{@_=keys%a;while($k=shift@_){$s{"@_"}++&¨grep($h{$_}{$k},%h)?push@_,$k:($h{$k}=print$k)}}
|
#!perl -lan
($l,$r)=@F;$s{$r}{$l}=1if$l ne$r;$s{$l}||={};END{while(($l)=grep!%{$s{$_}},keys%s){print$l;delete$s{$_}{$l}for keys%s;delete$s{$l}}%s&&die}
|
#!perl -lan
@a{@F}=($l,$r)=@F;$h{$l}{$r}=$l ne$r;END{@_=keys%a;while($k=shift@_){$s{"@_"}++&¨push(@_,$k),next if grep$h{$_}{$k},%h;print$k;$h{$k}=1}}
|
#!perl -lan
@a{@F}=($l,$r)=@F;$h{$l}{$r}=1if$l ne$r;END{@_=keys%a;while($k=shift@_){$s{"@_"}++&¨push(@_,$k),next if grep$_->{$k},values%h;print$k;$h{$k}=1}}
|
#!perl -lan
($l,$r)=@F;@a{@F}=1;$h{$l}{$r}=1if$l ne$r;END{@_=keys%a;while($k=shift@_){$s{"@_"}++&¨push(@_,$k),next if grep$_->{$k},values%h;print$k;$h{$k}=1}}
|
#!perl -lan
($l,$r)=@F;@a{@F}=1;$h{$l}{$r}=1if$l ne$r;END{@_=keys%a;while($k=shift@_){$s{"@_"}++&¨push(@_,$k),next if grep$_->{$k},values%h;print$k;delete$h{$k}}}
|
#!perl -ln
/(\S+) +(.+)/;$n{$1}+=0;++$n{$2},push@{$s{$1}},$2if$1ne$2;END{@_=grep!$n{$_},keys%n;print&&push@_,grep!--$n{$_},@{$s{$_}}while$_=pop@_;$n{$_}&&die for keys%n}
|
#!perl -lan
my($l,$r)=@F;$n{$l}+=0;next if$l eq$r;++$n{$r};push@{$s{$l}},$r;END{@_=grep{!$n{$_}}keys%n;while(@_){$_=pop@_;print;push@_,grep!--$n{$_},@{$s{$_}}}$n{$_}&&die for keys %n}
|