Sum on parallelepiped
Easy
Execution time limit is 1 second
Runtime memory usage limit is 122.174 megabytes
The three dimensional matrix of integers a[ijt]
is given, where 1 ≤ i ≤ n, 1 ≤ j ≤ m, 1 ≤ t ≤ k. For given l[x]
, l[y]
, l[z]
, r[x]
, r[y]
, r[z]
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 a[ijt]
(1 ≤ a[ijt]
≤ 1000). The blocks are separated with empty line. Next line gives the number of queries q (1 ≤ q ≤ 10^6
). Next q lines contains the queries lx[i]
, ly[i]
, lz[i]
, rx[i]
, ry[i]
, rz[i]
(1 ≤ lx[i]
≤ rx[i]
≤ n, 1 ≤ ly[i]
≤ ry[i]
≤ m, 1 ≤ lz[i]
≤ rz[i]
≤ k).
Output
Print the answers in q separate lines.
Examples
Input #1
Answer #1
Submissions 760
Acceptance rate 29%