<>;$r[$_]=++$=for glob<>;map{$d=$r[$o[$_]=$_.$/]if$d<$r[$_]}glob<>;print@o