P29407 [洛谷] [COCI2010-2011#4] ASTRO
普及
题目描述

Problem Description

There are two stars, each blinking at regular intervals.

Given the initial blinking times and the intervals between blinks for both stars, you need to determine the first time they blink simultaneously.

Note: The initial blinking day is a Saturday, and 00:00 marks the first minute of the day.

Input Format

The input consists of four lines.

Each line contains a time in the format HH:MM (hours:minutes), representing:
1. The initial blinking time of the first star.
2. The initial blinking time of the second star.
3. The interval between blinks of the first star.
4. The interval between blinks of the second star.

The first two times are guaranteed to be different and on a Saturday. The intervals are not 00:00.

Output Format

If the stars never blink simultaneously, output Never.

Otherwise, output two lines:
1. A string indicating the day of the week when they first blink simultaneously.
2. A time in the same format as the input, indicating the specific time of that day when they blink simultaneously.

Correct spelling for the days of the week (from Sunday to Saturday):
Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday.

If $HH<10$, a leading zero should be included.

Sample Input and Output

Sample Input #1

02:20
13:00
05:50
01:00

Sample Output #1

Saturday
14:00

Sample Input #2

02:20
23:28
00:40
23:50

Sample Output #2

Never

Sample Input #3

23:19
10:19
02:42
09:11

Sample Output #3

Thursday
00:31

Notes

Data Size and Constraints

  • For 40% of the test cases, the intervals are whole hours, i.e., $MM=0$; for example, 13:00.
  • For 100% of the test cases, $0 \le HH \le 23$ and $0 \le MM \le 59$.

Source

Translated from COCI2010-2011 CONTEST #4 T3 ASTRO.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
02:20 13:00 05:50 01:00
样例输出
Saturday 14:00