Under construction

Still being built. Things may change

Rhonda

Time limit1sMemory limit1024 MB

Summary
Given several 10x10 layers, sum the layers named in each data set cell by cell and print each resulting 10x10 grid.
Level

Easy2 of 10

Topics
Implementation, Matrix
Solved
No attempts yet

Problem

Rhonda prints processor chips. Each chip is made from fabricated components inscribed onto thin layers. She stacks two or more layers together to create a final chip made up of multiple layers.

Rhonda has several unique layers. She can combine them in various numbers to make a variety of chips. Each layer is a 10x10 grid of integers, and each cell holds an integer from 0 to 9. The final chip is also a 10x10 grid. Each cell is the sum of the values in that same position across the layers used to make the chip.

Layers are numbered in the order given, starting at zero. For example, combining only the first and second layers gives the data set 0 1.

The value of each cell in an individual layer is in the range 0 to 9. The value of each cell in a final chip is in the range 0 to 99. All original layers are unique.

Input

The first line contains an integer i, the number of unique layers. Next come i grids of 10x10 integers, each followed by a newline. The next line contains a positive integer n, the number of data sets. Each data set is one line of integers separated by spaces. These integers are the numbers of the layers used to make a chip.

Output

Print the summed chip for each data set as a 10x10 grid. Each cell is shown as two digits, with one space between cells.

Examples1

  1. Example 1

    Input
    3
    0101010101
    0101010101
    0101010101
    0101010101
    0101010101
    0101010101
    0101010101
    0101010101
    0101010101
    0101010101
    
    0123456789
    0123456789
    0123456789
    0123456789
    0123456789
    0123456789
    0123456789
    0123456789
    0123456789
    0123456789
    
    7386459728
    3748244739
    8420475820
    1938475283
    3847520734
    5826752039
    4230489329
    4594890835
    2188305727
    4320834420
    
    3
    0 1
    0 1 2
    0 0 0 0 0 0 0 0 0 0
    
    Expected output
    00 02 02 04 04 06 06 08 08 10
    00 02 02 04 04 06 06 08 08 10
    00 02 02 04 04 06 06 08 08 10
    00 02 02 04 04 06 06 08 08 10
    00 02 02 04 04 06 06 08 08 10
    00 02 02 04 04 06 06 08 08 10
    00 02 02 04 04 06 06 08 08 10
    00 02 02 04 04 06 06 08 08 10
    00 02 02 04 04 06 06 08 08 10
    00 02 02 04 04 06 06 08 08 10
    
    07 05 10 10 08 11 15 15 10 18
    03 09 06 12 06 10 10 15 11 19
    08 06 04 04 08 13 11 16 10 10
    01 11 05 12 08 13 11 10 16 13
    03 10 06 11 09 08 06 15 11 14
    05 10 04 10 11 11 08 08 11 19
    04 04 05 04 08 14 15 11 10 19
    04 07 11 08 12 15 06 16 11 15
    02 03 10 12 07 06 11 15 10 17
    04 05 04 04 12 09 10 12 10 10
    
    00 10 00 10 00 10 00 10 00 10
    00 10 00 10 00 10 00 10 00 10
    00 10 00 10 00 10 00 10 00 10
    00 10 00 10 00 10 00 10 00 10
    00 10 00 10 00 10 00 10 00 10
    00 10 00 10 00 10 00 10 00 10
    00 10 00 10 00 10 00 10 00 10
    00 10 00 10 00 10 00 10 00 10
    00 10 00 10 00 10 00 10 00 10
    00 10 00 10 00 10 00 10 00 10