/*

 * The key to this problem is to calculate everything

 * in fractional form until display time

 */


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

typedef struct {
   unsigned long long numerator;
   unsigned long long denominator;
} slot_or_peg_t;

slot_or_peg_t pegs[5][9];  /* game board: 5 rows, 9 columns */
slot_or_peg_t slots[5][9]; /* arrival probabilities         */
int           num_paths[5][9];

void getBoard (void)
{
   int row, col;
   for (row = 1; row < 5; row++)
   {
      for (col = 1 - (row % 2); col < 9; col+=2)
      {
         scanf("%d/%d", 
              &pegs[row][col].numerator,
              &pegs[row][col].denominator);
      }
   }
}

slot_or_peg_t
multiply ( slot_or_peg_t a, slot_or_peg_t b)
{
   slot_or_peg_t c;
   c.numerator = a.numerator * b.numerator;
   c.denominator = a.denominator * b.denominator;
   return c;
}

slot_or_peg_t
add ( slot_or_peg_t a, slot_or_peg_t b)
{
   slot_or_peg_t c;
   c.numerator   = a.numerator * b.denominator 
                 + b.numerator * a.denominator;
   c.denominator = a.denominator * b.denominator;
   return c;
}

slot_or_peg_t
reverse ( slot_or_peg_t a )
{
   slot_or_peg_t c;
   c.numerator   = a.denominator - a.numerator;
   c.denominator = a.denominator;
   return c;
}


int main (void)
{
   int dataset_count, i, j, k;
   int row, col;

   scanf("%d", &dataset_count);

   for (i = 0; i < dataset_count; i++)
   {
      getBoard();

      printf("data set #%d\n", i+1);
      fflush(stdout);

      for (j=0;j<3;j++) 
      {
         char start_char, end_char;
         int  start_col , end_col ;

         /* get the start/end info */ 
         scanf(" %c %c", &start_char, &end_char);

         /* convert it to column indicies */
         start_col = (start_char - 'A') * 2;
         end_col   = (  end_char - 'A') * 2;

         /* now create a new board with arrival probabilities */
         for (row = 0; row < 5; row++)
         {
            for (col = row % 2; col < 9; col+=2)
            {
               slots[row][col].numerator   = 0;
               slots[row][col].denominator = 1;
               num_paths[row][col]         = 0;
            }
         }

         /* seed it with the starting location */
         slots[0][start_col].numerator = 1;
         num_paths[0][start_col]       = 1;

         /* process all the other locations */
         for (row = 1; row < 5; row++)
         {
            for (col = row % 2; col < 9; col+=2)
            {
               if (col > 0) /* possible move from left */
               {
                  slots[row][col] = 
                     add ( 
                         multiply                ( 
                            slots[row-1][col-1], 
                            pegs[row][col-1]     ),
                         slots[row][col] 
                         );
                  if ( pegs[row][col-1].numerator > 0 )
                  {
                     num_paths[row][col] += num_paths[row-1][col-1];
                  }
               }
               if (col < 8) /* possible move from right */
               {
                  slots[row][col] = 
                     add ( 
                         multiply                     ( 
                            slots[row-1][col+1], 
                            reverse(pegs[row][col+1]) ),
                         slots[row][col] 
                         );
                  if ( pegs[row][col+1].numerator < pegs[row][col+1].denominator )
                  {
                     num_paths[row][col] += num_paths[row-1][col+1];
                  }
               }
            }
         }
         /* done calculating probabilities */

         printf("%c->%c %lu paths, %d%% chance\n", 
                 start_char, end_char, num_paths[4][end_col],
                 ( (100 * slots[4][end_col].numerator) / slots[4][end_col].denominator) );
         fflush(stdout);

      }
      /* done with this data set */

   }

   return 0;
}