{"problem":{"name":"Misjudge the Time","description":{"content":"Takahashi bought a table clock.   The clock shows the time as shown in Figure 1 at $\\mathrm{AB}$:$\\mathrm{CD}$ in the $24$\\-hour system.   For example, the clock in Figure 2 shows 7:58. > The format ","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc278_b"},"statements":[{"statement_type":"Markdown","content":"Takahashi bought a table clock.  \nThe clock shows the time as shown in Figure 1 at $\\mathrm{AB}$:$\\mathrm{CD}$ in the $24$\\-hour system.  \nFor example, the clock in Figure 2 shows 7:58.\n\n> The format of the time is formally described as follows.  \n> Suppose that the current time is $m$ minutes past $h$ in the $24$\\-hour system. Here, the $24$\\-hour system represents the hour by an integer between $0$ and $23$ (inclusive), and the minute by an integer between $0$ and $59$ (inclusive).  \n> Let $A$ be the tens digit of $h$, $B$ be the ones digit of $h$, $C$ be the tens digit of $m$, and $D$ be the ones digit of $m$. (Here, if $h$ has only one digit, we consider that it has a leading zero; the same applies to $m$.)  \n> Then, the clock shows $A$ in its top-left, $B$ in its bottom-left, $C$ in its top-right, and $D$ in its bottom-right.\n\n![image](https://img.atcoder.jp/ghi/abc278_fd0f03726830bf6d87eafff6aaedb0634b1aa7577b2dd043fc5b5a7870f4e12b.png)\nTakahashi has decided to call a time **a confusing time** if it satisfies the following condition:\n\n*   after swapping the top-right and bottom-left digits on the clock, it still reads a valid time in the $24$\\-hour system.\n\nFor 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.\nThe clock now shows $H$:$M$.  \nFind the next confusing time (including now) in the $24$\\-hour system.\n\n## Constraints\n\n*   $0 \\leq H \\leq 23$\n*   $0 \\leq M \\leq 59$\n*   $H$ and $M$ are integers.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$H$ $M$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc278_b","tags":[],"sample_group":[["1 23","1 23\n\n1:23 is a confusing time because, after swapping its top-right and bottom-left digits on the clock, it reads 2:13.  \nThus, the answer is 1:23.  \nYour answer is considered correct even if you print `01 23` with a leading zero."],["19 57","20 0\n\nThe next confusing time after 19:57 is 20:00."],["20 40","21 0\n\nNote that 24:00 is an invalid notation in the $24$\\-hour system."]],"created_at":"2026-03-03 11:01:13"}}