$s.=chop while$_=(sort map{$|=print$s.$_|0 x10,$/;my$_=<>.$_;/u/?exit:$_}0..9)[9]