ACSL

American Computer Science League

Time Zones

PROBLEM: Given day and time information for one city, find the day and time information of a second city. Starting in Greenwich, England the earth is divided into time zones based upon longitude. Time zones are 15 degrees wide and are labeled east or west based upon the direction from Greenwich. Greenwich has a longitude of 0 degrees. The time zone lines are numbered in this way through 165 degrees. The longitude line at 180 degrees is not designated east or west and is known as the International Date Line (IDL). A simple diagram is shown below:

IDL / 165 / 150 / 135 / 120 / 105 / 90 / 75 / 60 / 45 / 30 / 15 / 0 / 15 / 30 / 45 / 60 / 75 / 90 / 105 / 120 / 135 / 150 / 165 / IDL
| / | / | / | / | / | / | / | / | / | / | / | / | / | / | / | / | / | / | / | / | / | / | / | / |
/ W / E /
165W / IDL / 165E
WEST / / | / | / | / / EAST
SAT / SUN

If you travel east you must add one hour to the time for each time zone line crossed. If you travel west and cross a time zone line you must subtract one hour from the time. If you cross the IDL going west you must also advance the day. If you cross the IDL going east you must also change the day to one-day earlier.

INPUT: There will be 10 input lines. Each line will contain 4 data items: 1) a character string representing the longitude of the starting location, 2) a 3-character string giving the day at the starting location, 3) a 4-character string representing the time at the starting location in HHXM format on a 12-hour clock, and 4) a character string representing the longitude of the second location. Travel will always be the shortest distance between the two locations. Sample Input Line #1 states that the starting longitude is 4 degrees East, the day is Saturday, the starting location time is 06AM and the second location’s longitude is 23 degrees East.

OUTPUT: For each input line, print the day and time at the second location. The time will be printed in the same format as the input time: HHXM. Sample Output #1 is calculated by noting that the shortest distance between the two locations is found by traveling east and that one time zone line is crossed. One hour is added to the starting time.

SAMPLE INPUTSAMPLE OUTPUT

1. 4E, SAT, 06AM, 23E1. SAT, 07AM

2. 157W, MON, 07AM, 110W2. MON, 10AM

3. 77W, FRI, 08PM, 149W3. FRI, 04PM

4. 5E, TUE, 09AM, 153E4. TUE, 07PM

5. 153E, WED, 09PM, 5E5. WED, 11AM

6. 170E, SAT, 06PM, 140W6. FRI, 09PM

7. 140W, SAT, 06PM, 170E7. SUN, 03PM

ACSL

American Computer Science League

Time Zones
TEST DATA
TEST INPUTTEST OUTPUT

1. 25E, MON, 08AM, 28E1. MON, 08AM

2. 40E, MON, 09AM, 50E2. MON, 10AM

3. 25W, TUE, 10AM, 65W3. TUE, 07AM

4. 155W, WED, 11PM, 89W4. THU, 04AM

5. 89W, WED, 11PM, 155W5. WED, 06PM

6. 140E, THU, 10PM, 20E, 6. THU, 02PM

7. 20E, THU, 10PM, 140E7. FRI, 06AM

8. 160W, FRI, 02PM, 160E8. SAT, 11AM

9. 160E, FRI, 02PM, 160W9. THU, 05PM

10. 15W, SAT, 08AM, 15E10. SAT, 09AM