P6484 [COCI 2010/2011 #4] ASTRO
Description
There are two stars. Each of them flashes once every fixed period of time.
Now you are given the time when each star flashes for the first time, and the interval between two flashes for each star. You need to find on which day and at what time the two stars flash simultaneously for the first time.
**Note: the day when the flashing starts is Saturday, and `00:00` is the first minute of a day.**
Input Format
The input consists of four lines.
Each line contains a time in the form `HH:MM` (hours:minutes), in order: the initial flashing time of the first star; the initial flashing time of the second star; the flashing interval of the first star; the flashing interval of the second star.
It is guaranteed that the times in the first two lines are different and both are on Saturday; the intervals will not be `00:00`.
Output Format
If the two stars will never flash at the same time, output `Never`.
Otherwise output two lines. The first line is a string indicating the day of the week when they first flash simultaneously. The second line is a time in the same format as the input, indicating the exact time of that simultaneous flash on that day.
Correct spellings of the words (from Sunday to Saturday) are:
`Sunday` `Monday` `Tuesday` `Wednesday` `Thursday` `Friday` `Saturday`.
If $HH
Explanation/Hint
#### Constraints
- For $40\%$ of the testdata, the interval is an integer number of hours, i.e. $MM=0$; for example, `13:00`.
- For $100\%$ of the testdata, $0\le HH\le 23$, $0\le MM\le 59$.
#### Notes
**Translated from [COCI2010-2011](https://hsin.hr/coci/archive/2010_2011/) [CONTEST #4](https://hsin.hr/coci/archive/2010_2011/contest4_tasks.pdf) *T3 ASTRO***。
Translated by ChatGPT 5