<>; @a=map s/\n/~/r,<>; while("@a"=~/\w/){ @a=sort@a; $a[0]=~s/.//; $\.=$&; } print