-- Practice yukicoder -- author: Leonardone @ NEETSDKASU main = interact $ unlines . map (unwords . map (show . floor) . last) . filter (not . null) . head . until (null . last) (zipWith ($) [foldl1 (++) . zipWith ($) [return . minimum . head, last] . repeat . reverse, foldl1 (filter . (/=) . head) . zipWith ($) [return . minimum, id] . repeat . last] . repeat) . (:) [] . return . map (zipWith ($) [return . foldl1 (/), id] . repeat . map read . words) . tail . lines