<>; $a[$_]=++$%for glob<>; $m>$a[$_]or$h{$_}=$m=$a[$_]for glob<>; $,=$/;print sort{$a-$b}keys%h