Push-To Telescope

Time limit1sMemory limit128 MB

Problem

Once a Push-To telescope is set up, it tells you where to point the telescope to see a star in its built-in catalogue by giving an azimuth (the counter-clockwise angle in the base plane of the telescope) and an elevation (the angle above the base plane of the telescope).

The telescope is initialized by pointing it at a known star, finding that star in the catalogue, and selecting it. This step is repeated with a second known star that is not too close to the first one.

The direction of stars in the catalogue is given in geocentric equatorial coordinates. The origin is the center of the earth. The positive $z$-axis passes through the North Pole and the $xy$-plane contains the equator. The $x$-axis points at the sun at the spring equinox (when the sun is in the equatorial plane). A star's coordinates are its right ascension $\alpha$ (the angle in the $xy$-plane, counter-clockwise from the $x$-axis, in degrees) and its declination $\delta$ (the angle above (positive) or below (negative) the $xy$-plane).

In this coordinate system the earth rotates at $\dfrac{2\pi \cdot 1.0027379093}{86400}$ radians per second. (Because the earth also moves around the sun, it must rotate slightly more than $360^\circ$ to bring the sun back over the same point.)

During setup, when you select a star, the system records the time (in seconds since the system was turned on), the azimuth and elevation of the telescope while pointing at the star, and the index of the star in the table. After two selections of known stars, the system computes the transformation from geocentric equatorial coordinates to local (telescope) coordinates. Subsequently, when you select a star to view, the system uses the star's geocentric equatorial coordinates and the current time to compute the azimuth and elevation to point at.

Write a program that implements the Push-To telescope.

Because the telescope coordinate system rotates with the earth, it is convenient to use a rotating geocentric equatorial coordinate system for star coordinates. This system aligns with geocentric equatorial coordinates at the moment the system turns on and rotates with the earth thereafter. In this system the declination $\delta$ is unchanged, but the right ascension changes with time:

$$\alpha_{rot} = \alpha - t \cdot \text{rotation_rate}$$

where $\alpha_{rot}$ is the right ascension in the rotating system (in radians), $\alpha$ is the right ascension in geocentric equatorial coordinates (in radians), $t$ is the time in seconds since the system was turned on, and $\text{rotation_rate}$ is the earth's rotation rate defined above.

Input

The first line contains two integers separated by a single space. The first integer is the number of stars in the catalogue $S$ ($0 < S \le 100$) and the second is the number of data sets $P$ ($0 < P < 100$).

The next $S$ lines form the star table. Each line contains two floating-point values separated by spaces: the right ascension $\alpha$ and the declination $\delta$, in degrees. There is a single star table, and it is used for all data sets. Each data set is processed identically and independently using this table.

The $P$ data sets follow the star table. Each data set consists of several lines. The first line of a data set contains one integer, the number of stars to find $T$ ($T \le 10$).

The next two lines give the setup data for the data set. Each setup line consists of two integers followed by two floating-point values. The integers are $t$, the number of seconds since the system was started, and $I$, the index of the known setup star in the table. The floating-point values are the azimuth and elevation of that star in degrees (in telescope coordinates).

The remaining $T$ lines of the data set each specify a star the user wants to observe. Each line contains two integers separated by spaces: the first is the time (in seconds) since the system was started, and the second is the index of the star to observe in the table.

Star indices are $1$-based.

Output

Print several lines of output for each data set. For each star to be observed, print one line. If the computed elevation is less than zero (the star is below the horizon), print the string NOT VISIBLE (without the quotes). Otherwise print the azimuth and elevation, in degrees, to one decimal place. The azimuth is normalized to the range $[0, 360)$.