while True:
    try:
        n,m,q = map(int,input().split())
        data = []
        for i in range(n):
            data.append(list(map(int,input().split())))
        dp = [[0 for _ in range(m)] for i in range(n)]
        dp[0][0] = data[0][0]
        for j in range(1,m):
            dp[0][j] = dp[0][j-1]+data[0][j]
        for i in range(1,n):
            dp[i][0] = dp[i-1][0]+data[i][0]
        for i in range(1,n):
            for j in range(1,m):
                dp[i][j] = dp[i][j-1]+dp[i-1][j]-dp[i-1][j-1]+data[i][j]
        for i in range(q):
            x1,y1,x2,y2 = map(int,input().split())
            if x1 == 1 and y1 == 1:
                res = dp[x2-1][y2-1]
            elif x1 == 1:
                res = dp[x2-1][y2-1]-dp[x2-1][y1-2]
            elif y1 == 1:
                res = dp[x2-1][y2-1]-dp[x1-2][y2-1]
            else:
                res = dp[x2-1][y2-1]-dp[x2-1][y1-2]-dp[x1-2][y2-1]+dp[x1-2][y1-2]
            print(res)
    except:
        break