Problems
Sum on parallelepiped
Sum on parallelepiped
The three dimensional matrix of integers aijt
is given, where 1 ≤ i ≤ n, 1 ≤ j ≤ m, 1 ≤ t ≤ k. For given lx
, ly
, lz
, rx
, ry
, rz
find
Input
First line contains the size of the matrix - n, m, k (1 ≤ n, m, k ≤ 100). Then given n blocks with m lines, each line contains k integers aijt
(1 ≤ aijt
≤ 1000). The blocks are separated with empty line. Next line gives the number of queries q (1 ≤ q ≤ 106
). Next q lines contains the queries lxi
, lyi
, lzi
, rxi
, ryi
, rzi
(1 ≤ lxi
≤ rxi
≤ n, 1 ≤ lyi
≤ ryi
≤ m, 1 ≤ lzi
≤ rzi
≤ k).
Output
Print the answers in q separate lines.
Input example #1
2 3 5 1 2 3 4 5 5 4 3 2 1 2 3 1 5 4 1 2 3 4 5 5 4 3 2 1 2 3 1 5 4 5 1 1 1 1 2 2 1 1 1 2 2 2 1 2 3 2 3 4 1 3 4 2 3 5 1 2 4 2 2 5
Output example #1
12 24 22 18 6