#include <stdio.h>

/* Size of city in columns */
#define COLS 10

/* Size of city in rows */
#define ROWS 10

/* Maximum height of any building/point */
#define MAXHEIGHT 10

/* Holds the heights for all city blocks */
int height[ROWS][COLS];

/* A 3 dimenstional vector (in the math sense) used for computations */
class point {

    public:
        double x, y, z;

    inline point(void) : x(0), y(0), z(0) {}
    inline point(double x, double y, double z) : x(x), y(y), z(z) {}
};

/* Adding/subtracting vectors together adds/subtracts individual dimensions */
inline point const operator+(point const &a, point const &b) {
    return point(a.x + b.x, a.y + b.y, a.z + b.z);
}
inline point const operator-(point const &a, point const &b) {
    return point(a.x - b.x, a.y - b.y, a.z - b.z);
}

/* Multiplying by a scalar, simply scales length of the vector */
inline point const operator*(point const o, double i) {
    return point(i * o.x, i * o.y, i * o.z);
}
inline point const operator*(double i, point const o) {
    return point(i * o.x, i * o.y, i * o.z);
}

/* Multiplying vectors together computes dot product */
inline double operator*(point const &a, point const &b) {
    return (a.x * b.x) + (a.y * b.y) + (a.z * b.z);
}

/* Initialize board layout from the input */
void parse_city(void)
{
    int row, col;
    
    /* Iterate over all rows and columns */
    for(row = 0; row < ROWS; row++) {
        for(col = 0; col < COLS; col++) {
            char c;
            
            /* Parse the next input character */
            if (scanf(" %c", &c) != 1)
                throw "Error parsing building height";
            
            /* Check for invalid input */
            if(c < '0' || c > '9')
                throw "Invalid input height";
                
            /* Convert to number and assign to array */
            height[row][col] = c - '0';	    
        }       
    }    
}

/* Parse a 3D coordinate of the form "(x, y, z)" and return as a point object */
point parse_point(void)
{
    double x, y, z;

    /* Parse the floating point numbers */
    if(scanf(" ( %lf , %lf , %lf )", &x, &y, &z) != 3)
        throw "Error parsing point";

    /* Check for invalid coordinate points */
    if(x < 0 || y < 0 || z < 0 || x > COLS || y > ROWS || z > MAXHEIGHT)
        throw "Invalid coordinate";
        
    /* Return newly constructed point object */
    return point(x, y, z);
}

/* Compute intersections with all vertical planes */
bool process_cols(point const &start, point const &end)
{
    /* Normal vector to all planes running vertically on city grid */
    point normal(1, 0, 0);

    /* Denominator for the intersection equation */
    double denom = normal * (end - start);

    /* If denom is 0, line is parallel to planes and they cannot obscure sight */
    if (denom < 0.00001 && denom > -0.00001)
        return true;
        
    /* Intersect with each vertical column */
    for(double x = 0; x <= COLS; x += 1.0) {
        point intersect;
        int row, col;
        double u;
    
        /* A single point on the plane */
        point plane(x, 0, 0);
        
        /* Compute paramter u at point of intersection */
        u = (normal * (plane - start)) / denom;

        /* Compute exact point of intersection */
        intersect = start + u * (end - start);
                
        /* Ignore intersections outside the start/end line segment */
        if(u < 0 || u > 1)
            continue;
            
        /* Compute the row on the city grid where intersection occurs */
        row = (int) intersect.y;
        if(row == ROWS)
            row = ROWS;
            
        /* Check height of the building to the right of the plane */
        col = (int) (x < COLS ? x : COLS - 1);
        if (intersect.z < height[row][col])
            return false;

        /* Check height of the building to the left of the plane */
        col = (int) (x >= 1 ? x - 1 : x);
        if (intersect.z < height[row][col])
            return false;
    }
    
    /* If no intersections were inside a building, player may be visible */
    return true;
}

/* Compute intersections with all horizontal planes */
bool process_rows(point const &start, point const &end)
{
    /* Normal vector to all planes running horizontally on city grid */
    point normal(0, 1, 0);

    /* Denominator for the intersection equation */
    double denom = normal * (end - start);
    
    /* If denom is 0, line is parallel to planes and they cannot obscure sight */
    if (denom < 0.00001 && denom > -0.00001)
        return true;
        
    /* Intersect with each vertical column */
    for(double y = 0; y <= ROWS; y += 1.0) {
        point intersect;
        int row, col;
        double u;
    
        /* A single point on the plane */
        point plane(0, y, 0);
        
        /* Compute paramter u at point of intersection */
        u = (normal * (plane - start)) / denom;
        
        /* Ignore intersections outside the start/end line segment */
        if(u < 0 || u > 1)
            continue;
            
        /* Compute exact point of intersection */
        intersect = start + u * (end - start);
        
        /* Compute the column on the city grid where intersection occurs */
        col = (int) intersect.x;
        if (col == COLS)
            col = COLS;
            
        /* Check height of the building south of the plane */
        row = (int) (y < ROWS ? y : ROWS - 1);
        if (intersect.z < height[row][col])
            return false;

        /* Check height of the building north of the plane */
        row = (int) (y >= 1 ? y - 1 : y);
        if (intersect.z < height[row][col])
            return false;
    }
    
    /* If no intersections were inside a building, player may be visible */
    return true;
}

/*
 * Compute the visibility between "start" point and another point read in
 * from the input. A line segment can be expressed using the following
 * parametric vector equation:
 *
 * P = P0 + u(P1 - P0)
 * 
 * Where "P0" is the starting point, "P1" is the ending point, "u" is the
 * parameter which ranges between 0.0 and 1.0 inclusive, and "P" is some point
 * along the line.
 *
 * A plane may also be expressed using the following vector equation:
 *
 * N dot (P - P2) = 0
 *
 * Where "N" is the normal vector (i.e. perpendicular) to the plane, "P2" is
 * a point on the plane itself, and "P" is any other point on the plane.
 *
 * The intersection between line and plane occurs at point "P" and solving
 * for parameter "u" gives:
 *
 * u = ( N dot (P2 - P0)) / (N dot (P1 - P0))
 *
 * The city can be divided into 11 horizontal and vertical planes (2 planes
 * on the edges and 9 planes between blocks). The line is intersected with
 * each of these planes, and the height of intersection is compared to the
 * appropriate building height.
 */
bool process_point(point const &start)
{
    /* Parse the other player's position */
    point end = parse_point();
    
    /* Check visibility against vertical planes */
    if(!process_cols(start, end))
        return false;

    /* Check visibility against horizontal planes */
    if(!process_rows(start, end))
        return false;

    /* If line intersects no buildings, then the player is visible */
    return true;
}

/* Main body of program */
void process(void)
{
    int city_num, city_idx;
    
    /* Read how many boards are to be analyzed */
    if(scanf(" %d", &city_num) != 1)
        throw "Error parsing number of cities";

    /* Process each board separately */
    for(city_idx = 0; city_idx < city_num; city_idx++) {
        int i;

        /* Initialize building heights from input */
        printf("Fragfest City #%d\n", city_idx + 1);
        parse_city();
        
        /* Parse starting position */
        point start = parse_point();
        
        /* Compute for each player separately */
        for(i = 0; i < 3; i++) {
            printf("Player %c is %s\n", i + 'A',
                process_point(start) ? "in sight" : "hiding");
        }       
    }
}

/* Run program and print out any exceptions that occur */
int main(void)
{
    /* Run main body of code */
    try {
        process();
    }
    
    /* Catch any internally generated exceptions */
    catch(char const *e) {
        fprintf(stderr, "%s\n", e);
    }
    
    return 0;
}