An integer r, representing the number of rows in a grid (1 ≤ r ≤ 10^6).
An integer c, representing the number of columns in a grid (1 ≤ c ≤ 10^6).
An integer q, representing the number of queries (1 ≤ q ≤ 10^4).
A 2D grid of size r*c, where each grid cell contains an integer (0 ≤ grid[i][j] ≤ 2^31 - 1).
A list of q queries, where each query consists of four integers r1, c1, r2, and c2 (0 ≤ r1, r2 < r, 0 ≤ c1, c2 < c).

### Example Input:
```
3 3 4
1 2 3
4 2 2
2 1 1
0 0 2 2
0 0 1 1
1 0 1 0
0 1 1 2
```

### Function Signature:
def f(r: int, c: int, q: int, grid: List[List[int]], queries: List[Tuple[int, int, int, int]]): 
    '''
    r: an integer
    c: an integer
    q: an integer
    grid: a 2D list of integers
    queries: a list of tuples, each containing four integers
    '''