The GoC Timber Mafia is notorious for its deforestation
activities in the forests near Siruseri. These activities have
increased multifold after the death of the bandit who used to
lord over these jungles.  Having lost the battle to prevent the
Mafia from illegally felling the teak trees in this forest, the
government of Siruseri came up with a novel idea.  Why not
legalise the deforestation activity and at least make some money
in the process? So the Government decided to lease out parts of
the forest to the Timber Mafia.
Most of the teak trees in the forests of Siruseri were planted
during the colonial times, after the native trees had been cut.
Like everything European, the forest is very regular and
orderly. It is rectangular in shape and the trees are arranged in
uniformly spaced rows and coloumns.
Since the trees differ in height and girth, the timber value
differs from tree to tree.  The forest department has collected
data on each tree and knows the volume of wood (in cubic feet)
available in each tree in the forest.
The forest department maintains this information in the form of
an $M \times N$ array of integers, where the
$(i, j)$th entry is the volume, in cubic feet, of the
$i^{th}$ tree on the $i^{th}$ row (or, equivalently, the
$i^{th}$ tree on the $i^{th}$ column).  We assume that
our rows are numbered top to bottom and the columns are numbered
from left to right.  For example, such an array could look like

This array tells us that  the volume of the tree at position $(3,4)$ is $15$
cubic feet and so on.
Any rectangular piece of land with trees at each corner can be
leased out.  In order to fix the lease price for any rectangular
plot of the forest the forest department needs to know the amount
of wood available inside the plot.
A rectangular plot is described by the positions of the trees in
its top left corner and the bottom right corner. For example the
positions $(2,2)$ and $(3,4)$ describes the following part
rectangular part of the above forest.

The total amount of wood available in this rectangular plot is $76$
cubic feet.  Similarly $(4,2)$ and $(4,2)$ describes the rectangle
with just one tree and its volume is $20$ cubic feet.
Your task is to write a program that helps the forest department
to compute the total volume of the trees insides any specfied
rectangular plot.

-----Input:-----
- The first line of the input contains two integers $M$ and $N$ indicating the number of rows and columns of trees in the forest. 
- The following $M$ lines have $N$ integers each. The $j^{th}$ integer on line $i+1$ denotes the volume (in cubic feet) of the $j^{th}$  tree on the $i^{th}$  row. 
- Line $M+2$ contains a single integer $C$ indicating the number of rectangles for which the total volume is to be computed. 
- Each of the following $C$ lines (line $M+2+1 ... M+2+C$) contain four integers $x_1, y_1, x_2$ and $y_2$ (with $x_1 \leq x_2$ and $y_1 \leq y_2$) and describes a rectangle. The rectangle has its top left corner at the tree in position $(x_1,y_1)$ and its bottom right corner at the tree at position $(x_2,y_2)$.

-----Output:-----
Your output must contain $C$ lines with one integer on each line. Line $i$ must contain the total volume of wood in the rectangle described on line $M+2+i$ in the input.

-----Constraints-----
- In $30 \%$ of inputs, $1 \leq C \leq 100$.
- In all inputs, $2 \leq N, M \leq 1000$ and $1 \leq C \leq 1000000$
- $0 \leq$ volume of wood in each tree $\leq 1000$
- $1 \leq x_1 \leq x_2 \leq M$
- $1 \leq y_1 \leq y_2 \leq N$

-----Sample Input-----
4 4 
3 4 15 23 
14 20 12 9
3 8 12 15
12 20 7 5
2
2 2 3 4 
4 2 4 2

-----Sample Output-----
76
20

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = "# cook your dish here\nfrom sys import stdin, stdout\nrows,columns=map(int,stdin.readline().strip().split())\nmatrix=[]\nfor _ in range(rows):\n row=list(map(int,stdin.readline().strip().split()))\n matrix.append(row)\nC=int(stdin.readline().strip())\nfor _ in range(C):\n tlx,tly,brx,bry=map(int,stdin.readline().strip().split())\n s=0\n for r in range(tlx-1,brx):\n  for c in range(tly-1,bry):\n   s+=matrix[r][c]\n stdout.write(str(s)+'\\n')"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13579