-- Practice yukicoder -- author: Leonardone @ NEETSDKASU main = interact $ concat . concat . zipWith ($) [foldl1 ((return .) . (. head) . take . minimum . map read), foldl1 ((return .) . ((concat . zipWith ($) [return . head, tail . reverse . tail, return . last] . repeat) .) . (reverse .) . (. head) . drop . read . head) . zipWith ($) [return . show . (+0) . minimum . map read . head, foldl1 ((return .) . (. head) . take . (+1) . maximum . map read)] . repeat, foldl1 ((return .) . (. head) . drop . (+1) . maximum . map read)] . repeat . reverse . map words . lines