Welcome to ZOJ
Select Problem
ZOJ Problem Set - 4113

Time Limit: 1 Second      Memory Limit: 65536 KB

On a planet far away from Earth, one year is composed of 12 months, and each month always consists of 30 days.

Also on that planet, there are 5 days in a week, which are Monday, Tuesday, Wednesday, Thursday and Friday. That is to say, if today is Monday, then tomorrow will be Tuesday, the day after tomorrow will be Wednesday. After 3 days it will be Thursday, after 4 days it will be Friday, and after 5 days it will again be Monday.

Today is the $d_1$-th day in the $m_1$-th month of year $y_1$. Given the day of today on that planet, what day will it be (or was it) on the $d_2$-th day in the $m_2$-th month of year $y_2$ on that planet?


There are multiple test cases. The first line of the input contains an integer $T$ (about 100), indicating the number of test cases. For each test case:

The first line contains three integers $y_1$, $m_1$, $d_1$ ($2000 \le y_1 \le 10^9$, $1 \le m_1 \le 12$, $1 \le d_1 \le 30$) and a string $s$, indicating the date and day of today on that planet. It's guaranteed that $s$ is either "Monday", "Tuesday", "Wednesday", "Thursday" or "Friday".

The second line contains three integers $y_2$, $m_2$ and $d_2$ ($2000 \le y_2 \le 10^9$, $1 \le m_2 \le 12$, $1 \le d_2 \le 30$), indicating the date whose day we want to know.


For each test case output one line containing one string, indicating the day of the $d_2$-th day in the $m_2$-th month of year $y_2$ on that planet.

Sample Input

2019 5 12 Monday
2019 5 14
2019 5 12 Tuesday
2019 12 30
2019 5 12 Friday
1000000000 1 1
1000000000 1 1 Wednesday
2019 5 12

Sample Output


Author: WENG, Caizhi
Source: The 10th Shandong Provincial Collegiate Programming Contest
Submit    Status