{-# LANGUAGE TupleSections #-}

import Control.Monad
import Data.Array.Unboxed

main = join $ sub <$> get

sub [h,w,n] = sol h w n <$> replicateM n get >>= put

get = fmap read . words <$> getLine

put = mapM_ print

sol h w n ps = if n>0 then elems sm else replicate 10 0
  where
  bnds = ((0,0),(h+1,w+1))
  ar = accumArray (+) 0 bnds $ zip
    (concatMap (\[a,b] -> range ((a-1,b-1),(a+1,b+1))) ps)
    (repeat 1) :: UArray (Int,Int) Int
  sm = accumArray (+) 0 (0,9) . fmap ((,1) . (ar!)) $
    range ((2,2),(h-1,w-1)) :: UArray Int Int