A, B, S = gets.chomp.split time = Time.new(2021, 1, 1, A.to_i, B.to_i) if S[3] == '+' offset = S[4..-1].to_f - 9 time += offset * 3600 else offset = 9 + S[4..-1].to_f time -= offset * 3600 end puts "%02d:%02d" % [time.hour, time.min]