# your code goes here l=STDIN.gets n, h, m, t=l.split(" ") a=Time.new(1970,1,1,h.to_i,m.to_i,0) a=a+60*t.to_i*(n.to_i-1) puts a.hour puts a.min