import java.io.*;
import java.text.*;
import java.util.*;

public class soccer {
  public static void main(String[] args) throws Exception {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int S = Integer.parseInt(in.readLine());
        NumberFormat format = NumberFormat.getInstance(Locale.US);
        format.setMinimumFractionDigits(2);
        format.setMaximumFractionDigits(2);
        for (int scen=1; scen <= S; ++scen) {
            System.out.println("Scenario #"+scen+":");
            String[] teams = new String[16];
            for (int i=0; i < teams.length; ++i) {
              teams[i] = in.readLine();
              assert(teams[i].matches("[a-zA-Z]{1,10}"));
            }
            double[][] win = new double[16][16];
            for (int i=0; i < win.length; ++i) {
              String[] tokens = in.readLine().trim().split(" +");
              assert(tokens.length == 16);
              for (int j=0; j < tokens.length; ++j) {
                win[i][j] = 1.0/100*Integer.parseInt(tokens[j]);
              }
            }
            double[][] prob = new double[16][16];
            for (int i=0; i < 16; ++i) {
              prob[i][i] = 1.0;
            }
            double[] p = new double[16];
            for (int n=16; n > 1; n /= 2) {
              for (int i=0; i < n/2; ++i) {
                Arrays.fill(p,0);
                for (int s=0; s < 16; ++s) {
                  for (int t=0; t < 16; ++t) {
                    p[s] += prob[2*i][s]*prob[2*i+1][t]*win[s][t];
                    p[t] += prob[2*i][s]*prob[2*i+1][t]*win[t][s];
                  }
                }
                System.arraycopy(p,0,prob[i],0,16);
              }
            }
            for (int i=0; i < 16; ++i) {
              System.out.print(teams[i]);
              for (int j=teams[i].length(); j < 11; ++j) System.out.print(" ");
              String result = format.format(prob[0][i]*100);
              for (int j=result.length(); j < 6; ++j) System.out.print(" ");
              System.out.println(result);
            }
            System.out.println();
        }
  }
}
