Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/integer-dars-tugash-vaqti

Lesson end time

Medium 1000 ms 64 MB 38%
Share

Lessons start at $h$ hours $m$ minutes. Each lesson lasts $a$ minutes, and there is a $b$-minute break between two consecutive lessons. Find the hour and the minute when lesson $k$ ends. For example, if lessons start at $8{:}00$, $a = 45$ and $b = 5$, lesson $2$ ends at $9{:}35$.

Diagram of the sequence of lessons and breaks

Input

One line with five integers: $h$, $m$, $a$, $b$ and $k$.

Output

One line with two integers: hours and minutes.

Note

$0 \le h \le 23$
$0 \le m \le 59$
$1 \le a \le 120$
$0 \le b \le 60$
$1 \le k \le 10$
Lesson $k$ ends on the same day, no later than $23{:}59$.

Examples

Input #1
8 0 45 5 2
Output #1
9 35
Input #2
13 30 40 10 1
Output #2
14 10

Sign in to submit a solution

Signing up is free and takes a minute.