The first query covers 1, 2, 4, and 5, whose sum is 12. The second query covers the whole grid, whose sum is 45. The third query covers 5, 6, 8, and 9, whose sum is 28.
Output
12
45
28
Input
2 2 3
5 3
2 8
1 1 1 1
2 2 2 2
1 1 2 2
Explanation
The first two queries ask for single cells with values 5 and 8. The last query asks for the whole grid, so 5 + 3 + 2 + 8 = 18.