while (line = gets) do

  hour = 60 * 60
  min = 60
  sec = 1

  times = line.split.map(&:to_i)

  start_time = times[0] * hour + times[1] * min + times[2] * sec
  end_time = times[3] * hour + times[4] * min + times[5] * sec

  working_time = end_time - start_time

  formatted_time = Array.new(3)

  formatted_time[0] = working_time / hour > 0 ? working_time / hour : 0
  formatted_time[1] = (working_time / min) % min > 0 ? (working_time / min) % min : 0
  formatted_time[2] = working_time % min

  puts "#{formatted_time[0]} #{formatted_time[1]} #{formatted_time[2]}"
end