F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

3D Puzzles

Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 524288/262144 K (Java/Others)
Total Submission(s): 53    Accepted Submission(s): 11


Problem Description
Klee likes toys. Klee's mom, Alice bought her a new toy from Sumeru.

The toy is a $4\times 4\times 4$ cube. The cube can be divided into $13$ different parts of the blocks.

The $13$ blocks are shown in the figure.



Each block can be placed anywhere in the cube, but cannot overlap.

Klee can freely rotate the blocks and use a kind of magic, mirror magic. After using mirror magic, the blocks will flip symmetrically. For example, block F is shown in the figure after using mirror magic.



At the beginning, Alice has put some blocks in place. Klee needs to put the remaining blocks into a $4\times 4\times 4$ cube.

Using Astrology, Alice knew the number of solutions will not exceed $500$.

Klee wants to know all the solutions of this puzzle, but it is too difficult for Klee. Please help her.
 

Input
Each test contains multiple test cases. The first line contains the number of test cases $T(1 \le T \le 10)$. Description of the test cases follows.

There are $16$ lines in a case. Each line contains a string of $4$ characters. Every $4$ lines describe one layer of the cube from top to bottom.

Each input character may only be upper-case letters from "A" to "M" or ".".

"A" to "M" are indicating the blocks in the figure above and "." are indicating the position is empty.
 

Output
For each test case:

If it's impossible to solve the puzzle, print "No Solution!" in a single line (without quotes).

Otherwise, print the number of solutions in the first line.

Then for each solution, print $16$ lines. Each line contains a string of $4$ characters. Every $4$ lines describe one layer of the cube from top to bottom.

Each input character may only be upper-case letters from "A" to "M", indicating the blocks in the figure above.

The output format of block is the same as input.

If there are multiple solutions, print them in the lexicographical order.
 

Sample Input
2 E... EEE. E... ...L E... .... .... ...L JJ.. GJ.. GII. HIIL JJ.. JJ.. GII. HIIM E... EEE. E... ...L E... .... .... ...L JJ.. GJ.. G... H..L JJ.. JJ.. G... H..M
 

Sample Output
1 ECCC EEEC EDDD BDDL ECKK AAAA BDDA BBBL JJKK GJFA GIIA HIIL JJKK JJFF GIIF HIIM 2 ECCC EEEC EDDD BDDL ECKK AAAA BDDA BBBL JJKK GJFA GIIA HIIL JJKK JJFF GIIF HIIM EKKK EEEA EBBA DDBL EKKK AAAA DDBA DDDL JJII GJII GFBC HFFL JJII JJII GCCC HCFM
 

Hint

3D Model for the first example.
Download and open it with paint 3D.
https://share.weiyun.com/5iX1150Z
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2025 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2025-04-01 06:24:12, Gzip enabled