#P2010. ACSL 2015-2016 Senior Division Contest #3 ACSL ABC

ACSL 2015-2016 Senior Division Contest #3 ACSL ABC

Easy as ABC is a puzzle game by Wei-Hwa Huang. In the puzzle the given letters are placed in the grid so that each letter appears just once in each row and column. Further, letters are given outside the grid. These letters tell that that letter will be the first found in that row or column staring from that direction. In addition some cells in the puzzle will be filled ( ) at the start of the game. The game is played on a 4 x 4 grid. The grid uses cells 8 – 11, 14 – 17, 20 – 23 and 26 – 29. The other cells are used to place first found letters. The A in Grid #2 is at location #7. Cells 1, 6, 31 and 36 are not used.

INPUT FORMAT

There will be 5 lines of input. Each line will contain the location number of the 4 filled cells. That will be followed by the number of first found letters given and their value and location. The input data for Grid #2 is given in Sample Input #1.

OUTPUT FORMAT

For each input line print the letters of the resulting grid in numerical order. Do not print the fill characters.

SAMPLE

INPUT

9, 17, 22, 26, 4, A, 7, C, 18, C, 19, C, 32
11, 16, 20, 27, 4, A, 7, B, 19, A, 24, B, 30
9, 14, 23, 28, 3, B, 7, C, 25, A, 30
8, 15, 23, 28, 4, A, 7, C, 24, C, 33, A, 30
9, 16, 23, 26, 4, A, 7, B, 19, B, 25, B, 18

OUTPUT

ABCBACCBACAB
ACBBACBCACAB
BACACBACBCBA
ABCCABABCBCA
ABCCABBCABCA