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