Global Roaming

Time limit1sMemory limit128 MB

Summary
Given a satellite position and a list of ground locations on a sphere, decide which locations have the satellite above their horizon.
Level

Medium4 of 10

Topics
Geometry, Math, Implementation
Solved
No attempts yet

Problem

A great deal of today's mobile communication relies on having a direct line of sight to a satellite. For communication providers it is therefore crucial to know where their services are available.

You must identify the locations that have a direct line of sight to a given satellite; that is, the satellite must be above the horizon. To simplify the computation, assume that the earth is a perfect sphere with a radius of 63786378 km (mountains will be added next year...). The satellite is treated as a point-like object above the earth's surface.

Input

The input consists of several test cases. The first line of each test case contains the number of locations nn to be checked, followed by the position of the satellite: its latitude, its longitude (both in degrees), and its height (in km) above the earth's surface.

Each of the following nn lines describes one location on the earth's surface: the location's label (a string of fewer than 6060 printable ASCII characters containing no whitespace) followed by its latitude and longitude (both in degrees).

The input is terminated by a line with n=0n=0.

Output

For each test case, first print a line of the form Test case k:, where kk is the test-case number starting from 11. Then print the labels of the locations from which the satellite is visible, one per line, in the same order as they appear in the input.

Separate two consecutive test cases with a single blank line.

Examples1

  1. Example 1

    Input
    3 20.0 -60.0 150000000.0
    Ulm       48.406    10.002
    Jakarta   -6.13     106.75
    Honolulu  21.32    -157.83
    2 48.4 10 0.5
    Ulm       48.406    10.002
    Honolulu  21.32    -157.83
    0 0.0 0.0 0.0
    
    Expected output
    Test case 1:
    Ulm
    Honolulu
    
    Test case 2:
    Ulm