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

public class Ceramic {
  static final int DIM = 6;
  static final int TILES = 9;


  static int[][][][] tileMap = // tileMap[shape][rot][square (1-3, assume 0)][x=0,y=1]
      new int[7][4][3][2];

  static {
    //XXXX
    tileMap[0][0][0][0] = 1;
    tileMap[0][0][0][1] = 0;
    tileMap[0][0][1][0] = 2;
    tileMap[0][0][1][1] = 0;
    tileMap[0][0][2][0] = 3;
    tileMap[0][0][2][1] = 0;

    // 90
    tileMap[0][1][0][0] = 0;
    tileMap[0][1][0][1] = 1;
    tileMap[0][1][1][0] = 0;
    tileMap[0][1][1][1] = 2;
    tileMap[0][1][2][0] = 0;
    tileMap[0][1][2][1] = 3;

    // other two are same
    tileMap[0][2][0][0]= -100;
    tileMap[0][3][0][0]= -100;
    

    // XX
    // XX
    tileMap[1][0][0][0] = 1;
    tileMap[1][0][0][1] = 0;
    tileMap[1][0][1][0] = 0;
    tileMap[1][0][1][1] = 1;
    tileMap[1][0][2][0] = 1;
    tileMap[1][0][2][1] = 1;

    tileMap[1][1][0][0] = -100;
    tileMap[1][2][0][0] = -100;
    tileMap[1][3][0][0] = -100;
    
    // XX
    //  XX
    tileMap[2][0][0][0] = 1;
    tileMap[2][0][0][1] = 0;
    tileMap[2][0][1][0] = 1;
    tileMap[2][0][1][1] = 1;
    tileMap[2][0][2][0] = 2;
    tileMap[2][0][2][1] = 1;

    // 90
    //  X
    // XX
    // X
    tileMap[2][1][0][0] = 0;
    tileMap[2][1][0][1] = 1;
    tileMap[2][1][1][0] = -1;
    tileMap[2][1][1][1] = 1;
    tileMap[2][1][2][0] = -1;
    tileMap[2][1][2][1] = 2;

    tileMap[2][2][0][0] =-100;
    tileMap[2][3][0][0] =-100;


    //  XX
    // XX
    tileMap[3][0][0][0] = 1;
    tileMap[3][0][0][1] = 0;
    tileMap[3][0][1][0] = 0;
    tileMap[3][0][1][1] = 1;
    tileMap[3][0][2][0] = -1;
    tileMap[3][0][2][1] = 1;

    // 90
    // X
    // XX
    //  X
    tileMap[3][1][0][0] = 0;
    tileMap[3][1][0][1] = 1;
    tileMap[3][1][1][0] = 1;
    tileMap[3][1][1][1] = 1;
    tileMap[3][1][2][0] = 1;
    tileMap[3][1][2][1] = 2;
    
    tileMap[3][2][0][0] = -100;
    tileMap[3][3][0][0] = -100;


    // X
    // XXX
    tileMap[4][0][0][0] = 0;
    tileMap[4][0][0][1] = 1;
    tileMap[4][0][1][0] = 1;
    tileMap[4][0][1][1] = 1;
    tileMap[4][0][2][0] = 2;
    tileMap[4][0][2][1] = 1;

    // 90
    // XX
    // X
    // X
    tileMap[4][1][0][0] = 1;
    tileMap[4][1][0][1] = 0;
    tileMap[4][1][1][0] = 0;
    tileMap[4][1][1][1] = 1;
    tileMap[4][1][2][0] = 0;
    tileMap[4][1][2][1] = 2;

    // 180
    // XXX
    //   X
    tileMap[4][2][0][0] = 1;
    tileMap[4][2][0][1] = 0;
    tileMap[4][2][1][0] = 2;
    tileMap[4][2][1][1] = 0;
    tileMap[4][2][2][0] = 2;
    tileMap[4][2][2][1] = 1;

    // 270
    //  X
    //  X
    // XX
    tileMap[4][3][0][0] = 0;
    tileMap[4][3][0][1] = 1;
    tileMap[4][3][1][0] = 0;
    tileMap[4][3][1][1] = 2;
    tileMap[4][3][2][0] = -1;
    tileMap[4][3][2][1] = 2;


    // XXX
    // X
    tileMap[5][0][0][0] = 1;
    tileMap[5][0][0][1] = 0;
    tileMap[5][0][1][0] = 2;
    tileMap[5][0][1][1] = 0;
    tileMap[5][0][2][0] = 0;
    tileMap[5][0][2][1] = 1;

    // 90
    // XX
    //  X
    //  X
    tileMap[5][1][0][0] = 1;
    tileMap[5][1][0][1] = 0;
    tileMap[5][1][1][0] = 1;
    tileMap[5][1][1][1] = 1;
    tileMap[5][1][2][0] = 1;
    tileMap[5][1][2][1] = 2;

    // 180
    //   X
    // XXX
    tileMap[5][2][0][0] = 0;
    tileMap[5][2][0][1] = 1;
    tileMap[5][2][1][0] = -1;
    tileMap[5][2][1][1] = 1;
    tileMap[5][2][2][0] = -2;
    tileMap[5][2][2][1] = 1;

    // 270 
    // X
    // X
    // XX
    tileMap[5][3][0][0] = 0;
    tileMap[5][3][0][1] = 1;
    tileMap[5][3][1][0] = 0;
    tileMap[5][3][1][1] = 2;
    tileMap[5][3][2][0] = 1;
    tileMap[5][3][2][1] = 2;

    //  X
    // XXX
    tileMap[6][0][0][0] = 0;
    tileMap[6][0][0][1] = 1;
    tileMap[6][0][1][0] = 1;
    tileMap[6][0][1][1] = 1;
    tileMap[6][0][2][0] = -1;
    tileMap[6][0][2][1] = 1;

    // 90
    // X 
    // XX 
    // X
    tileMap[6][1][0][0] = 0;
    tileMap[6][1][0][1] = 1;
    tileMap[6][1][1][0] = 1;
    tileMap[6][1][1][1] = 1;
    tileMap[6][1][2][0] = 0;
    tileMap[6][1][2][1] = 2;

    // 180
    // XXX
    //  X  
    tileMap[6][2][0][0] = 1;
    tileMap[6][2][0][1] = 0;
    tileMap[6][2][1][0] = 2;
    tileMap[6][2][1][1] = 0;
    tileMap[6][2][2][0] = 1 ;
    tileMap[6][2][2][1] = 1;

    // 270
    //  X
    // XX 
    //  X
    tileMap[6][3][0][0] = 0;
    tileMap[6][3][0][1] = 1;
    tileMap[6][3][1][0] = -1;
    tileMap[6][3][1][1] = 1;
    tileMap[6][3][2][0] = 0 ;
    tileMap[6][3][2][1] = 2;
  }
  
  public static void main(String[] argv)
  throws Exception {
    
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
								 //new FileInputStream("example.in")));

    int N = Integer.parseInt(in.readLine().trim());

    for(int dataSet = 1;dataSet <= N; dataSet++){
      int[] tile = new int[TILES];
	
      System.out.println("Data Set "+dataSet);
      StringTokenizer t = new StringTokenizer(in.readLine());
      for(int i=0;i<TILES;i++)
	tile[i] = Integer.parseInt(t.nextToken())-1;
      
      char[][] floor = new char[DIM][DIM];
     
      if(placeATile(0, 0, floor, tile)){
	System.out.println("The floor may be tiled.");
	for(int y=0;y<DIM;y++){
	  for(int x=0;x<DIM;x++)
	    System.out.print(floor[x][y]);
	  System.out.println();
	}
      }
      else
	System.out.println("The floor may not be tiled.");

      System.out.println();
    }

    System.out.println("End of Output");

  }

  static boolean placeATile(int x, int y, char[][] floor, int[] tile)
  {
    for(int i=0;i<TILES;i++)
      if(tile[i]!=-1)
	if(copyTile(x, y, i, tile, floor)){
	  return true;
	}
    return false;
  }

  static boolean copyTile(int x, int y, int tileI, int[] tile, char[][] floor){
    for(int rot = 0;rot < 4;rot++)
      if(rotateCopy(x, y, tileI, tile, rot, floor))
	return true;
    return false;
  }

  static boolean rotateCopy(int x, int y, int tileI, int[] tile, int rot, char[][] floor){
    //int[][][][] tileMap = // tileMap[shape][rot][square (1-3, assume 0)][x=0,y=1]
    int shape = tile[tileI];
    if(floor[x][y]!='\0'){
      System.err.println("huh?");
      System.exit(1);
    }

    int newx1, newy1;
    newx1 = x+tileMap[shape][rot][0][0];
    newy1 = y+tileMap[shape][rot][0][1];
    if(!isLegal(newx1, newy1) || floor[newx1][newy1]!='\0')
      return false;

    int newx2, newy2;
    newx2 = x+tileMap[shape][rot][1][0];
    newy2 = y+tileMap[shape][rot][1][1];
    if(!isLegal(newx2, newy2) || floor[newx2][newy2]!='\0')
      return false;

    int newx3, newy3;
    newx3 = x+tileMap[shape][rot][2][0];
    newy3 = y+tileMap[shape][rot][2][1];
    if(!isLegal(newx3, newy3) || floor[newx3][newy3]!='\0')
      return false;

    floor[x][y] = (char)(tileI+'A');
    floor[newx1][newy1] = (char)(tileI+'A');
    floor[newx2][newy2] = (char)(tileI+'A');
    floor[newx3][newy3] = (char)(tileI+'A');

    int nextx=DIM, nexty=DIM;
    
    //System.out.println("trying "+((char)(i+'A'))+" shape "+tile[i]+
    //	     " at "+x+","+y);
    tile[tileI] = -1;

    GOTIT:
    for(nexty=y; nexty < DIM; nexty++)
      for(nextx = 0 ; nextx < DIM; nextx++)
	if(floor[nextx][nexty]=='\0')
	  break GOTIT;
    if(nextx == DIM && nexty == DIM)
      return true;

    if(placeATile(nextx, nexty, floor, tile))
      return true;
    
    //System.out.println("removing "+((char)(i+'A'))+" shape "+tile[i]+
    //	     " at "+x+","+y);
    tile[tileI] = shape;
    floor[x][y] = '\0';
    floor[newx1][newy1] = '\0';
    floor[newx2][newy2] = '\0';
    floor[newx3][newy3] = '\0';
    
    return false;
  }

  static final boolean isLegal(int x, int y){
    return x>=0 && x < DIM && y>=0 && y < DIM;
  }
}

    
