eval'_,*A='+$<.read.split*?, *x,y,z=A.sort;$><<[x,[y,z].rotate(z<=>A[-1])]*' '