## ADABASET - Ada and Database

Ada the Ladybug has inserted all data from her TODO-list into the database. The database is represented as multidimensional structure with direct indexing. Your task is simple - read the database and tell Ada the data on given indices!

### Input

There will be multiple test-cases.

The first line of each test-case contains **n** integers ** 1≤ D _{i} ≤ 10^{5} **, indicating the size of each dimense.

**n**will be between

**2**and

**10**. Their product won't exceed

**10**

^{6}Each of following **D _{1}×D_{2}×...×D_{n-1}** lines contains

**D**integers (where

_{n}**D**is size of last dimension), all between

_{n}**0**and

**10**.

^{18}Last line of each test-case contains 0 to 5 queries. Each query consists of **n** integers **A _{1}, ... ,A_{n}**, where

**1 ≤ A**(note that array is one-indexed).

_{i}≤ D_{i}Input file will have at most **2*10 ^{6}** integers. There won't be any other lines than those described above.

**NOTE:** If you are not confident about what number is on index **[A _{1}][A_{2}]...[A_{n}]**, imagine input as

**D**blocks of

_{1}**D**blocks of

_{2}**D**blocks of

_{3}**...**of

**D**integers.

_{n}### Output

For each query, output integer on indices **[A _{1}][A_{2}]...[A_{n}]** on a single line. After each test-case, output line with as many hashes ('#'), as the number of test-case (beginning with 1)

### Example Input

2 2 1 2 3 4 1 1 1 2 2 1 2 2 2 2 2 10 9 8 7 6 5 2 1 2 2 2 1 2 6 1 2 3 4 5 6 6 5 4 3 2 1 1 1 1 1 2 1

### Example Output

1 2 3 4 # 1 ## 1 6 ###

Added by: | Morass |

Date: | 2017-02-16 |

Time limit: | 4s |

Source limit: | 50000B |

Memory limit: | 1536MB |

Cluster: | Cube (Intel G860) |

Languages: | All |