ppAnt's Journey
Time Limit: 1 Second Memory Limit: 32768 KB
ppAnt loves travelling so much that he spends his life on the journey. It's a pity that he only recalls time and place when he visited big cities, but forgets other trivial activities on the way. Please help ppAnt to decide where he is on a specific day.
ppAnt's quite cute that he alawys travels along shortest path between big cities. Now let's suppose he travels with constant velocity between cities. The place of the cities are specified with longitude and latitude. For examples:
If ppAnt departed from city A on May the 3rd, 1981, arrived in city B on May the 7th, 1981, he should have been at C on the 4th of May.
You can always rest assured that the shortest path between A and B are uniquely decided.
Input
The first line of input is an integer n, the number of test cases.
Each test case is devided into two parts. The first part is in the form:
Year Month Day Longitude Latitude
1 <= Year <= 9999, 1 <= Month <= 12, 1 <= Day <= 31, 0.0 <= Longitude < 360.0, -90.0 <= Latitude <= 90.0.
The second part is in the form:
Year Month Day
Output
Print a line for each line in the second part of input.
If the date does not exist, or it is earlier than the earliest date in the first part, or it is later than the latest date in the first part, print "ERROR".
Otherwise, print the longitude and latitude on the specific date. Numbers should have two digits on the right of the decimal point. Longitude should be 0.00 if Latitude is 90.00 or -90.00.
Print a blank line after each case.
Sample Input
2 1981 5 3 0.0 0.0 1981 5 7 90.0 0.0 1981 5 4 1981 5 5 1981 5 6 1981 5 7 1981 5 3 1981 2 28 20 40 1981 5 3 40 20 1981 3 30 0 90 1990 1 1 90 0 1981 2 29 1981 3 1 1981 3 29 1981 3 30 1981 3 31 1981 4 1 1981 5 2 1981 5 3 1988 2 29
Sample Output
22.50 0.00 45.00 0.00 67.50 0.00 90.00 0.00 0.00 0.00 ERROR 20.00 41.67 20.00 88.33 0.00 90.00 40.00 87.94 40.00 85.88 40.00 22.06 40.00 20.00 79.84 4.79Submit
Source: ZOJ Monthly, January 2003