题目描述
Problem Description
Xiaoyuan is a clever child who often shares interesting content with the kids around him. Recently, he plans to explain the stereogram under colored parallel light to the children and asks you to help him draw it on a plane.
Xiaoyuan has a rectangular area of size m*n, with m*n grids of side length 1, each filled with some equally sized building blocks (the length, width, and height of the blocks are all 1).
For convenience, we assume this area faces south. Here is an example:

Xiaoyuan wants you to print the stereogram of these grids. We define each block as follows and will not perform any flips or rotations, strictly placing them in this form only (the left side is the pattern to be printed, and the right side corresponds to the decimal ASCII values of each position symbol, where the symbol with ASCII 32 is a space).

In a good optical environment, Xiaoyuan shines T beams of parallel light onto these blocks. These beams of light are always one of the three primary colors (red, green, blue), and their incident angles are multiples of 45 degrees with respect to the x-axis and y-axis; the angle with the positive z-axis is either 45 degrees, 0 degrees, or 315 degrees.
Specifically, we consider up to 9 different directions of parallel light, described as: Northwest at 45 degrees elevation, North at 45 degrees elevation, Northeast at 45 degrees elevation, West at 45 degrees elevation, vertical top-down light, East at 45 degrees elevation, Southwest at 45 degrees elevation, South at 45 degrees elevation, Southeast at 45 degrees elevation. For each unit block, the three printable surfaces are divided into 12 small triangles, as shown below (the symbols 0, 1, 2,... are used in the figure).

The three primary colors (red, green, blue) are represented by the letters RGB. The secondary colors (cyan, yellow, purple) resulting from two colors mixing are represented by CYP. The tertiary color, white, resulting from three colors mixing, is represented by W.
Input Format
The first line contains two positive integers m and n, indicating the area has m rows and n columns. The next m lines describe each row from far to near. Each line contains n positive integers, indicating the number of blocks stacked in the i-th row and j-th column. The following 3 lines, each containing three characters, describe the colors of the light in the 9 corresponding directions (same as the map description direction). Each character is either one of RGB, indicating the corresponding color, or *, indicating no light. These nine directions are: Northwest at 45 degrees elevation, North at 45 degrees elevation, Northeast at 45 degrees elevation, West at 45 degrees elevation, vertical top-down light, East at 45 degrees elevation, Southwest at 45 degrees elevation, South at 45 degrees elevation, Southeast at 45 degrees elevation.
Output Format
The output provides the printed effect. The output should not contain leading empty lines, nor should it have extra empty lines at the end. The first column of the output should not be all spaces, and there should be no extra spaces at the end of each line.
Sample Input and Output
Input Sample #1
2 2
2 1
1 1
R**
***
**G
Output Sample #1
+-------+
/Y\YYYY'/|
/YY.*'YY/G|
/.YYYY\Y/G/|
+-------+G.G|
|\GGGGG/|\:G|
|G\GGG/G|G*G|
|GG\G/GG|G:\|
|GGGXGGG|G'G+-------+
|GG/G\GG|/G/G\YYYY'/|
|G/GGG\G|G/GG.*'YY/G|
|/GGGGG\|/.GGGG\Y/G/|
+-------+-------+G.G|
/Y\GGGG'/G\GGGG'/|\:G|
/YY.*'GG/GG.*'GG/G|G*G|
/.YYYY\G/.GGGG\G/G/|G:\|
+-------+-------+G.G|G'G+
|\GGGGG/|\GGGGG/|\:G|/G/
|G\GGG/G|G\GGG/G|G*G|G/
|GG\G/GG|GG\G/GG|G:\|/
|GGGXGGG|GGGXGGG|G'G+
|GG/G\GG|GG/G\GG|/G/
|G/GGG\G|G/GGG\G|G/
|/GGGGG\|/GGGGG\|/
+-------+-------+
Input Sample #2
3 4
1 1 2 1
1 2 1 2
2 1 2 1
**B
***
R*G
Output Sample #2
+-------+
/W\WWWW'/|
/WW.*'WW/C|
/.WWWW\W/C/|
+-------+-------+-------+
/W\WWWW'/|\YYYYY/W\WWWW'/|
/WW.*'WW/C|G\YYY/WW.*'WW/C|
/.WWWW\W/C/|GG\Y/.WWWW\W/C/|
+-------+-------+-------+-------+C.C|---+
/W\WWWW'/|\YYYYY/W\WWWW'/|\YYYYY/|\:C|C'/|
/WW.*'WW/C|G\YYY/WW.*'WW/C|G\YYY/Y|C*C|C/C|
/.WWWW\W/C/|GG\Y/.WWWW\W/C/|GG\Y/YY|C:\|/C/|
+-------+C.G|GGG+-------+C.G|GGGXYYY|C'C+C.C|
|\YYYYY/|\:G|GG/|\YYYYY/|\:G|GG/G\YY|/C/|\:C|
|Y\YYY/Y|C*G|G/K|Y\YYY/Y|C*G|G/GGG\Y|C/C|C*C|
|YY\Y/YY|C:\|/KK|YY\Y/YY|C:\|/GGGGG\|/C/|C:\|
|YYYXYYY|C'G+---|YYYXYYY|C'G+-------+C.C|C'C+
|YY/Y\YY|/G/G\KK|YY/Y\YY|/G/G\GGGG'/|\:C|/C/
|Y/YYY\Y|G/GG.*'|Y/YYY\Y|G/GG.*'WW/C|C*C|C/
|/YYYYY\|/.YYYY\|/YYYYY\|/.WWWW\W/C/|C:\|/
+-------+-------+-------+-------+C.C|C'C+
|\YYYYY/|\YYYYY/|\YYYYY/|\YYYYY/|\:C|/C/
|Y\YYY/Y|Y\YYY/Y|Y\YYY/Y|Y\YYY/Y|C*C|C/
|YY\Y/YY|YY\Y/YY|YY\Y/YY|YY\Y/YY|C:\|/
|YYYXYYY|YYYXYYY|YYYXYYY|YYYXYYY|C'C+
|YY/Y\YY|YY/Y\YY|YY/Y\YY|YY/Y\YY|/C/
|Y/YYY\Y|Y/YYY\Y|Y/YYY\Y|Y/YYY\Y|C/
|/YYYYY\|/YYYYY\|/YYYYY\|/YYYYY\|/
+-------+-------+-------+-------+
Notes/Hints

For 15% of the data, 1 <= n, m <= 100, there is no incident light.
For 40% of the data, 1 <= n, m <= 100, there is only one beam of incident light, and the incident direction is definitely southeast.
For 100% of the data, 1 <= n, m <= 100, the total number of blocks stacked at each position does not exceed 100, and the color of the incident light can be any of RGB, with a maximum of 9 beams of incident light.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分