import Data.Maybe
import Control.Monad
import qualified Data.IntMap.Strict as M
import qualified Data.IntSet as S
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as B
 
(<+>) (x1,y1,z1) (x2,y2,z2) = (x1+x2, y1+y2, z1+z2)
(<->) (x1,y1,z1) (x2,y2,z2) = (x1-x2, y1-y2, z1-z2)
(!?) im k = M.findWithDefault (0,0,0) k im
(!*) v i = maybe (0,0,0) id (v V.!? i)
ix m x y = (x-1)*m + (y-1)

modulo = 10000
pos x y = modulo*x + y
north p = p - modulo
south p = p + modulo
east p = succ p
west p = pred p
 
main = do
 [n,m,q] <- map read . words <$> getLine
 ss <- concat <$> replicateM n getLine
 let idx = S.fromDistinctAscList $ map fst $ filter ((=='1').snd) $ zip [pos x y | x<-[1..n], y<-[1..m]] ss
 let aim = foldl (imos idx) M.empty [pos x y | x<-[1..n], y<-[1..m]]
 let vec = V.fromList (M.elems aim)
 qs <- map (map (fst . fromJust . B.readInt) . B.words) <$> replicateM q B.getLine
 mapM_ (print . query m vec) qs
 
link idx k
 | S.member k idx = (1, linkv, linkh)
 | otherwise = (0,0,0)
 where
  linkv = if S.member (north k) idx then 1 else 0
  linkh = if S.member (west k) idx then 1 else 0
 
imos idx acc k
 | div k modulo == 1 || mod k modulo == 1 = M.insert k v acc
 | otherwise = M.insert k (v <-> (acc !? ((north.west) k))) acc
  where v = link idx k <+> (acc !? (north k)) <+> (acc !? (west k))
 
query m vec [x1,y1,x2,y2] = ngrid - nlinkv - nlinkh
 where 
  ngrid = n0 - n1 - n2 + n3
  nlinkv = v0 - v4 - v2 + v6
  nlinkh = h0 - h7 - h1 + h9
  (n0,v0,h0) = vec !* (ix m x2 y2)
  (n1,_,h1) = vec !* (ix m (x1-1) y2)
  (n2,v2,_) = if y1 == 1 then (0,0,0) else vec !* (ix m x2 (y1-1))
  (n3,_,_) = if y1 == 1 then (0,0,0) else vec !* (ix m (x1-1) (y1-1))
  (_,v4,_) = vec !* (ix m x1 y2)
  (_,v6,_) = if y1 == 1 then (0,0,0) else vec !* (ix m x1 (y1-1))
  (_,_,h7) = vec !* (ix m x2 y1)
  (_,_,h9) = vec !* (ix m (x1-1) y1)