eolymp
bolt
Try our new interface for solving problems
Problems

Lord Bradley on the North Pole

Lord Bradley on the North Pole

A polar dawn is rising. Lord Bradley is standing precisely on the North Pole, facing the direction of his distant home at Greenwich. From throughout the whole Earth, angry polar bears are coming to seek revenge on him. Lord Bradley has only his good, faithful rifle. He never misses, and can take a shot (or any number of shots) in negligible time. The rifle has exceptional range - it can hit a target all the way up to the South Pole. The only problem is changing the shot direction: to keep his perfect concentration, Lord Bradley always turns at the speed of one arcsecond (\textbf{1}'' = \textbf{1}/\textbf{3600} * \textbf{1}°) per one "time" second. Will he manage to shoot all the bears, or will he become their breakfast? Suppose that Earth is perfectly spherical, its circumference is exactly \textbf{40 320} km, and all the bears are running straight at Bradley, with constant speed of \textbf{28} km/h. A bear can be shot even at point-blank range (at the very moment of entering the North Pole), however, shot direction in such a case should still be the direction the bear is approaching from. Given the initial geographic coordinates of all the bears, determine whether Lord Bradley survives this peril. \InputFile The first line contains the number \textbf{t} of test cases. The test cases follow. The first line of each test case contains a single integer \textbf{n} - the number of bears (\textbf{1} ≤ \textbf{n} ≤ \textbf{1 000}). In the next \textbf{n} lines, the bears' coordinates are given (latitude and longitude, using * for degrees, ' for minutes and " for seconds, as in the Examples section). None of the degrees, minutes and seconds can be omitted. All the numbers are nonnegative integers. As usual, \textbf{N} stands for nortern hemisphere and \textbf{S} for southern one, \textbf{E} for bears to the East of Greenwich and \textbf{W} for bears to the West. \OutputFile For each test case, your program should write a single line containing a single word: \textbf{ALIVE} if Bradley can defeat the bears, or \textbf{EATEN} otherwise.
Time limit 3 seconds
Memory limit 64 MiB
Input example #1
3
2
87*0'0"N 4*0'0"E
88*0'0"N 6*0'0"W
2
86*0'0"N 4*0'0"E
87*59'59"N 6*0'0"W
1
89*59'59"N 0*0'4"W
Output example #1
EATEN
ALIVE
ALIVE
Source 2013 Petrozavodsk Winter Training Camp, Jagiellonian University Contest, January 25, Problem L