## Dim Sum 4 - I'm Getting Bored

View as PDF

Points: 5
Time limit: 0.69s
Memory limit: 32M

Author:
Problem type

By now Dereck has become obsessed with the thought of dim sum. He has started to think of grids of dim sum in higher dimensions, and how their tastiness values will add up.

#### Input Specification

The first line of input will contain two integers , the number of dimensions of the shape Dereck is thinking of, and , the number of queries.

The next line of input contains one integer the depth of the shape.

The next line contains the full description of the shape.

The next lines contain a single integer, , the query.

#### Output Specification

lines containing the answers to the queries (the sum of the tastiness values in the th dimensional figure).

#### Sample Input 1

2 3
5
4 1 2 3 4 3 6 6 6 6 0 0 -1 0 0 0 2 24 24 2 50 50
2
3
4

#### Sample Output 1

18
-1
48

#### Sample Input 2

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

#### Sample Output 2

25
11
14
14

#### Sample Input 3

3 2
2
1 1 1 1 1 2
1
2

#### Sample Output 3

1
2