atcoder#ABC278B. [ABC278B] Misjudge the Time
[ABC278B] Misjudge the Time
Score : points
Problem Statement
Takahashi bought a table clock. The clock shows the time as shown in Figure 1 at : in the -hour system. For example, the clock in Figure 2 shows 7:58.
The format of the time is formally described as follows. Suppose that the current time is minutes past in the -hour system. Here, the -hour system represents the hour by an integer between and (inclusive), and the minute by an integer between and (inclusive). Let be the tens digit of , be the ones digit of , be the tens digit of , and be the ones digit of . (Here, if has only one digit, we consider that it has a leading zero; the same applies to .) Then, the clock shows in its top-left, in its bottom-left, in its top-right, and in its bottom-right.
Takahashi has decided to call a time a confusing time if it satisfies the following condition:
- after swapping the top-right and bottom-left digits on the clock, it still reads a valid time in the -hour system.
For example, the clock in Figure 3 shows 20:13. After swapping its top-right and bottom-left digits, it reads 21:03. Thus, 20:13 is a confusing time.
The clock now shows :. Find the next confusing time (including now) in the -hour system.
Constraints
- and are integers.
Input
The input is given from Standard Input in the following format:
Output
Let : be the answer, where and must satisfy and . Print and in the following format:
Your answer is considered correct even if contains a leading zero to represent it as a -digit integer; the same applies to .
1 23
1 23
1:23 is a confusing time because, after swapping its top-right and bottom-left digits on the clock, it reads 2:13.
Thus, the answer is 1:23.
Your answer is considered correct even if you print 01 23
with a leading zero.
19 57
20 0
The next confusing time after 19:57 is 20:00.
20 40
21 0
Note that 24:00 is an invalid notation in the -hour system.