#include <stdlib.h>
#include <stdio.h>
#include <math.h>

typedef struct {
   double x;
   double y;
   double z;
} coord_t;

int xstreet[10][10][10]; /* x,y,z : 1 <= x <= 9 */
int ystreet[10][10][10]; /* x,y,z : 1 <= y <= 9 */

coord_t location[4]; /* 0 => us, 1-3 => Players A-C */

void display()
{
   int x, y, z;

   for (y=0; y < 10; y++)
   {
      for (x=1; x < 10; x++)
      {
         if (xstreet[x][y][2] == 1) { printf("#"); }
         else                       { printf("."); } 
      }
      printf("\n");
   }

   for (y=1; y < 10; y++)
   {
      for (x=0; x < 10; x++)
      {
         if (ystreet[x][y][2] == 1) { printf("#"); }
         else                       { printf("."); } 
      }
      printf("\n");
   }
}

int hidden (coord_t a, coord_t b)
{
   double dx, dy, dz;
   double x, y, z, t;

   /* compute the differentials */
   dx = b.x - a.x;
   dy = b.y - a.y;
   dz = b.z - a.z;

   /*
    * formulas for projections of the line
    * on the x,z and y,z planes are:
    *  z = m1*x + b1
    *  z = m2*y + b2
    */

   /* look at x streets first */
   for (x = 1; x < 10; x++)
   {
      /* find the intersection with this street, if any */

      /* If we're parallel, we don't intersect */
      if (dx == 0 && x != a.x) { break; }

      /* Chech that we're between the two points */
      t = (x - a.x) / (dx);
      if (t < 0 || t > 1) { continue; }

      /* calculate y */
      if (dy == 0) { y = a.y; }
      else
      {
         y = (dy * t) + a.y;
      }

      /* calculate z */
      if (dz == 0) { z = a.z; }
      else
      {
         z = (dz * t) + a.z;
      }

      /* printf("Intersection (%lf,%lf,%lf)\n",x,y,z); */
      if (z > 9) { continue; }

      /* convert these to xstreet coordinates */
      if (xstreet[(int) x][(int) y][(int) z+1] == 1) { return 1; }
   }

   /* look at y streets next */
   for (y = 1; y < 10; y++)
   {
      /* find the intersection with this street, if any */

      /* If we're parallel, we don't intersect */
      if (dy == 0 && y != a.y) { break; }

      /* Chech that we're between the two points */
      t = (y - a.y) / (dy);
      if (t < 0 || t > 1) { continue; }

      /* calculate x */
      if (dx == 0) { x = a.x; }
      else
      {
         x = (dx * t) + a.x;
      }

      /* calculate z */
      if (dz == 0) { z = a.z; }
      else
      {
         z = (dz * t) + a.z;
      }

      /* printf("Intersection (%lf,%lf,%lf)\n",x,y,z); */
      if (z > 9) { continue; }

      /* convert these to xstreet coordinates */
      if (ystreet[(int) x][(int) y][(int) z+1] == 1) { return 1; }
   }

   return 0;
}

int main (void)
{
   int datasets, i, j;

   scanf(" %d ", &datasets);

   for (i = 0; i < datasets; i++)
   {
      char line[100];
      int x,y,z;

      /* clear the streets */
      memset(xstreet,0,1000*sizeof(int));
      memset(ystreet,0,1000*sizeof(int));

      for (y=0; y<10; y++)
      {
         /* read in the next line of buildings */
         scanf(" %s ", line);
         /* fill in values for this line */
         for (x=0; x<10; x++)
         {
            int height;
   
            height = line[x] - '0';
  
            /* mark buildings up to this height */
            for (z=1; z<=height; z++)
            {
               if (x > 0)  { xstreet[x][y][z] = 1; }
               if (y > 0)  { ystreet[x][y][z] = 1; }
               if (x < 9)  { xstreet[x+1][y][z] = 1; }
               if (y < 9)  { ystreet[x][y+1][z] = 1; }
            }
         }
      }
      /* done building downtown map */

      /* read in our position and player positions */
      for (j=0; j<4; j++)
      {
         int a;
         a = scanf(" (%lf, %lf, %lf) ", 
               &location[j].x, &location[j].y, &location[j].z);
      }

      /* test each player's sight line */
      printf("Fragfest City #%d\n", i+1);
      for (j=1; j<4; j++)
      {
         printf("Player %c is ", 'A'+(j-1));
         if (hidden(location[0],location[j]))
         {
            printf("hiding\n");
         }
         else
         {
            printf("in sight\n");
         }
      }
   }
   /* done processing all data sets */

   return;
}