was swimming around in his lake of money when he suddenly remembered that he forgot to water the Ooga crops at his Farm. He raced over to the crops as quickly as his muscular judo legs could take him and was shocked to find that his crops were sick and dying! They've been infected with the infamous Boronabirus and have turned a sickly gray colour.
After crying about it on Discord for another week,
decides enough is enough. He contacts Professor Dave, the only man powerful enough to solve this troubling predicament. Dr. Dave proposes that this is a job for the Oogabooganator 3000 GTX 1080 Pro Galaxy Plus Cherry MX Rainbow Alpha Beta Gamma Test Release, now with 50% reduced trans fat. Dave Phd. explains that the machine can supply Booga Juice to cure any rectangular section of the crops, provided you tell it how many Oogas are in that section.As usual,
needs your help to do this. As we all know, math isn't really his strong suit (and don't even get me started on his atrocious chess playing), so you have to help him count the Oogas in his crops so that they won't succumb to the dreaded BOVID-20!Input Specification
The first line of the input will contain integers and , denoting the width and length of the entire crop farm.
The next lines will contain integers denoting the number of Oogas found in each crop.
The next line of input is an integer , denoting the number of queries from the Oogabooganator.
The next lines will contain integers denoting the , , (of the top-left corner), , and of each section in the query.
For clarification, width refers to horizontal measure(x) and length refers to vertical(y).
Constraints
Output Specification
lines, denoting the number of Oogas in the section for each query.
Sample Input
4 5
7 6 2 7
5 10 6 9
9 10 7 2
9 3 4 4
7 4 9 2
6
2 1 3 2
3 3 1 3
2 4 3 1
3 3 1 3
4 2 1 3
2 1 2 4
Sample Output
40
20
11
20
15
48
Comments