import Data.Maybe
import Control.Monad
import Data.List
import Data.Char
import qualified Data.Vector.Unboxed as V
import qualified Data.ByteString.Char8 as B

asum = transpose . map (scanl1 (+)) . transpose . map (scanl1 (+))

linkh xs = zipWith (*) xs (tail xs)

main = do
 [n,m,q] <- map read . words <$> getLine
 sss <- map (B.foldr (\c acc -> digitToInt c : acc) []) <$> replicateM n B.getLine
 let lhs = map linkh sss
 let lvs = transpose . map linkh . transpose $ sss
 let vsss = V.fromList . concat . asum $ sss
 let vlhs = V.fromList . concat . asum $ lhs 
 let vlvs = V.fromList . concat . asum $ lvs
 qs <- map (map (pred . fst . fromJust . B.readInt) . B.words) <$> replicateM q B.getLine
 mapM_ (print . query m vsss vlhs vlvs) qs

query m vsss vlhs vlvs [x1,y1,x2,y2] = ngrid - nlinkh - nlinkv
 where
  (<->) a b = if mod a m == 0 then -1 else a-b
  pos vec x y = if x<0 || y<0 then 0 else vec V.! (x*m + y)
  posh vec x y = if x<0 || y<0 || mod y m == (m-1) then 0 else vec V.! (x*(m-1) + y)
  ngrid = pos vsss x2 y2 - pos vsss (x1-1) y2 - pos vsss x2 (y1-1) + pos vsss (x1-1) (y1-1)
  nlinkh = posh vlhs x2 (y2-1) - posh vlhs (x1-1) (y2-1) - posh vlhs x2 (y1-1) + posh vlhs (x1-1) (y1-1)
  nlinkv = pos vlvs (x2-1) y2 - pos vlvs (x1-1) y2 - pos vlvs (x2-1) (y1-1) + pos vlvs (x1-1) (y1-1)