#P4483. [BJWC2018] 神奇的钟点

[BJWC2018] 神奇的钟点

Description

One day, Xiao L saw three clocks showing 01:08\texttt{01:08}, 03:40\texttt{03:40}, and 13:52\texttt{13:52}. Xiao L noticed that each time is in the form hh:mm\texttt{hh:mm}, where hh\texttt{hh} is the hour and mm\texttt{mm} is the minute, and none of them is on the hour (i.e., 0hh<240\leqslant\texttt{hh}<24, 1mm<601\leqslant\texttt{mm}<60).

Recalling a lesson about ratios, hh:mm\texttt{hh:mm} also represents a ratio with value hhmm\frac{\texttt{hh}}{\texttt{mm}}. Then Xiao L discovered something magical: adding these three times yields 18:40\texttt{18:40}, which is also a valid time that is not on the hour (note the hour must be less than 2424). Its corresponding ratio 920\frac{9}{20} is exactly equal to the sum of the ratios 18\frac{1}{8}, 340\frac{3}{40}, and 14\frac{1}{4} of the three times!

Now Xiao L wants to know: among all triplets of times that satisfy this magical property, sorted in lexicographic order, what is the kk-th smallest?

Input Format

The input contains only a single positive integer kk.

Output Format

Output the kk-th smallest triplet that satisfies the magical property described in the statement, with the three times separated by a space; see the sample output. If the answer does not exist, output -1.

65432
01:08 03:40 13:52
1
00:01 00:01 00:01
58
00:01 00:02 00:01
2000000000
-1

Hint

【Sample Explanation】

Note that the times may be identical.

【Constraints】

For 30%30\% of the testdata, k1000k\leqslant 1000.
For 60%60\% of the testdata, k20000k\leqslant 20000.
For 100%100\% of the testdata, 1k2×1091\leqslant k\leqslant 2\times 10^9.

Translated by ChatGPT 5