import Control.Applicative
import Control.Monad


fromTimeToSec :: [Int] -> Int
fromTimeToSec [] = 0
fromTimeToSec (h:m:s:_) =
  let hsec = h * 3600
      msec = m * 60
  in
      hsec + msec + s
fromTimeToSec [_] = 0
fromTimeToSec [_, _] = 0

fromSecToTime :: Int -> [Int]
fromSecToTime sec =
  let s = sec `mod` 60
      m = (sec `mod` 3600) `div` 60
      h = sec `div` 3600
  in [h, m, s]

fromStoE :: [Int] -> [Int]
fromStoE [] = []
fromStoE (a:b:c:xs) = fromTimeToSec [a, b, c] : fromStoE xs
fromStoE [_] = []
fromStoE [_, _] = []

solver :: [[Int]] -> [[Int]]
solver [] = []
solver (x:xs) =
  let (b:e:_) = fromStoE x
      work = e - b
  in
      fromSecToTime work : solver xs

main :: IO()
main = do
  input <- map (map (read :: String -> Int) . words) <$> replicateM 3 getLine
  mapM_ ((putStrLn . unwords) . map show) (solver input)