What time will it be?

Work out the time on a 24-hour clock after some minutes have passed.

What to build

A program that converts a time into one number, does the arithmetic, and converts back.

Requirements

  • Read the hour, the minute and the number of minutes that pass.
  • Print the new hour and minute on one line, separated by a space.
  • The clock wraps past midnight, so the hour is always from 0 to 23.

Input

Three lines, each with one whole number.

Output

Two numbers on one line, with no leading zeros.

Constraints

The hour is 0 to 23, the minute is 0 to 59, and the passing minutes are 0 to 1000000.

Example

Input:

23
50
20

Output:

0 10

Why it works

Hours and minutes are awkward to add directly. As minutes since midnight, the sum is simple, and % 1440 does all the wrapping in a single step.

Examples

Example 1 · Input
23
50
20
Expected output
0 10
Example 2 · Input
9
5
70
Expected output
10 15

Prompts inside input() are ignored when checking, so input("n: ") is fine.

Hints

Hint 1

Turn the time into minutes since midnight first.

Hint 2

A day has 1440 minutes, so use % 1440 to wrap past midnight.

Hint 3

Then use // 60 and % 60 to get the hour and the minute.

Solution

Show one correct solution (try it yourself first)
hour = int(input())
minute = int(input())
passing = int(input())
total = (hour * 60 + minute + passing) % 1440
print(total // 60, total % 60)

Lesson: Numbers and operators →