P14042 [SDCPC 2019] Calandar

Description

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?

Input Format

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.

Output Format

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.