count, hour, minute, time = gets.chomp.split(" ").map(&:to_i) for i in 1...count do minute += time end printf "%d\n%d\n", hour, minute