Scanf.scanf "%d %d %d" (fun h w n ->
    let f a b = a lsl 30 + b in
    let module M = Map.Make (struct type t = int let compare = compare end) in

    let hist = Array.make 10 0 in
    hist.(0) <- (h - 2) * (w - 2);

    let rec loop i map =
        if i = n then hist else
            let map = Scanf.scanf " %d %d" (fun a b ->
                List.fold_left (fun map (vx, vy) ->
                    let x = b + vx in
                    let y = a + vy in
                    if x > 1 && x < w && y > 1 && y < h then (
                        let key = f x y in
                        let v = try M.find key map with _ -> 0 in
                        hist.(v) <- hist.(v) - 1;
                        hist.(v + 1) <- hist.(v + 1) + 1;
                        M.add key (v + 1) map
                    ) else map
                ) map [ -1, -1; -1, 0; -1, 1; 0, -1; 0, 0; 0, 1; 1, -1; 1, 0; 1, 1 ]
            ) in
            loop (i + 1) map
    in
    Array.iter (Printf.printf "%d\n") @@ loop 0 M.empty
)