Problem I. 23. A+B
Input file name: standard input
Output file name: standard output
Time limit: 1 s
Memory limit: 1024 MB
You are given two digits represented as 3 \times 5 matrices of characters ('X' for an active pixel, '0' for an inactive pixel). Each digit is provided in a "broken" state: exactly one 'X' pixel that should be active according to the standard font is instead rendered as a '0'.
Your task is to identify the two original digits, calculate their sum, and output that sum in its perfect (unbroken) 3 \times 5 matrix format.

The following 3 \times 5 grids define the standard appearance for digits 0-9. Any "broken" input is a modification of one of these templates.
0: 1: 2: 3: 4: XXX 00X XXX XXX X0X X0X 00X 00X 00X X0X X0X 00X XXX XXX XXX X0X 00X X00 00X 00X XXX 00X XXX XXX 00X 5: 6: 7: 8: 9: XXX XXX XXX XXX XXX X00 X00 00X X0X X0X XXX XXX 00X XXX XXX 00X X0X 00X X0X 00X XXX XXX 00X XXX XXX

Input

The input consists of two 3 \times 5 matrices, provided one after the other (10 lines total), representing two single digits (0-9). In each matrix, exactly one 'X' from the standard font has been replaced by a '0'.

Output

Identify the original digits. If the identified digits result in a unique possible sum, print the 3 \times 5 matrix (or matrices) representing that sum using the standard font.
  • If the sum is 0-9, output a single 3 \times 5 matrix.
  • If the sum is 10-18, output two 3 \times 5 matrices side-by-side, separated by a single space character.
  • If the original digits cannot be determined uniquely, or if they could represent multiple different sums, output -1.

Examples

standard inputstandard output
XXX X0X X0X X0X 0XX X0X X0X X0X X0X XXX XXX X0X X0X X0X XXX
X0X X0X XXX X0X XXX X0X 00X XXX X00 XXX 00X XXX 00X X0X 00X X0X 00X X0X 00X XXX
XXX X00 X0X X0X XXX XXX X00 X0X X0X XXX -1