module Main where type Input = [[Int]] type Output = [[Int]] parse :: String -> Input parse = map ( map read . words ) . tail . lines solve :: Input -> Output solve = let f xs | all p xs = xs | otherwise = f' xs where p = (>) ((sum xs + 1) `div` 2) f' xs@[a, b, c] | a == min = [min', b, c] | b == min = [a, min', c] | otherwise = [a, b, min'] where min = minimum xs max = maximum xs mid = sum xs - max - min min' = (max - mid) `div` min * min + min f' _ = [] in map f render :: Output -> String render = unlines . map ( unwords . map show ) main :: IO () main = interact ( render . solve . parse )