n, m, q = map(int,input().split())
#用画图求面积的方式,能够直观的体现算法
s = [[0]*(m+1) for _ in range(n+1)]#定义空白二位前缀和矩阵
for i in range(1,n+1):#初始化二位前缀和矩阵
    row = list(map(int,input().split()))#每行输入
    for j in range(1,m+1):
        s[i][j] = s[i-1][j]+s[i][j-1]-s[i-1][j-1]+row[j-1]

for _ in range(q):#进行查询操作
    x1, y1, x2, y2 = map(int,input().split())
    sumv = s[x2][y2]-s[x1-1][y2]-s[x2][y1-1]+s[x1-1][y1-1]
    print(sumv)#输出查询结果