Jetpack Sniper 3000 Fragfest Extreme

Time limit1sMemory limit128 MB

Problem

You are a beta tester for a new online game, Jetpack Sniper 3000 Fragfest Extreme. Players wearing jetpacks fly over a metropolitan area and try to shoot one another with laser guns. The only cover is the city's ever-present glass skyscrapers.

To help you play, you have written a program that reports which players you can currently shoot (or be shot by): the players who have an unobstructed straight-line view of your position.

Input

The first line contains a single integer $n$, the number of cities.

Each city is a $10 \times 10$ grid of city blocks. Every block holds one skyscraper whose integer height ranges from $0$ to $9$. A city is given as $10$ lines of $10$ digits; the digit in row $y$ (from the top, $0$-indexed) and column $x$ (from the left, $0$-indexed) is the height of the skyscraper occupying that block.

After the grid comes one line with four coordinate triples. The first is your position; the next three are the positions of players A, B, and C. Each position is written as (x, y, height), where $x$ increases from left to right, $y$ increases from top to bottom, and height is measured upward from the ground. The point $(0, 0, 0)$ is the top-left corner of the grid at ground level.

Notes:

  • Coordinates may be floating-point numbers.
  • No player (including you) is ever inside a building or on its surface, edges, or corners. No line of sight is tangent to a face, edge, or corner of a building in a way that would change the answer.

Output

For each city, print the header Fragfest City #X, where X is the city's number ($1$ for the first city, $2$ for the second, and so on). Then print one line for each of players A, B, and C, in that order: print Player Y is in sight if no building blocks your straight-line view of that player, or Player Y is hiding if a building obstructs it (Y is the player's letter).

Assume the following simplifications:

  1. Each skyscraper is a rectangular box of size $1 \times 1 \times \text{height}$.
  2. Each player is a single point.
  3. A player never blocks the view of another player.