Problem:
 Score : 400 points    Problem Statement We have a grid with H rows and W columns. At first, all cells were painted white.  Snuke painted N of these cells. The i -th ( 1 \leq i \leq N ) cell he painted is the cell at the a_i -th row and b_i -th column.  Compute the following:   For each integer j ( 0 \leq j \leq 9 ), how many subrectangles of size 3×3 of the grid contains exactly j black cells, after Snuke painted N cells?       Constraints  3 \leq H \leq 10^9  3 \leq W \leq 10^9  0 \leq N \leq min(10^5,H×W)  1 \leq a_i \leq H  (1 \leq i \leq N)  1 \leq b_i \leq W  (1 \leq i \leq N)  (a_i, b_i) \neq (a_j, b_j)  (i \neq j)         Input The input is given from Standard Input in the following format:  H  W  N  a_1  b_1 : a_N  b_N       Output Print 10 lines.
The (j+1) -th ( 0 \leq j \leq 9 ) line should contain the number of the subrectangles of size 3×3 of the grid that contains exactly j black cells.        Sample Input 1 4 5 8
1 1
1 4
1 5
2 3
3 1
3 2
3 4
4 4      Sample Output 1 0
0
0
2
4
0
0
0
0
0   There are six subrectangles of size 3×3 . Two of them contain three black cells each, and the remaining four contain four black cells each.       Sample Input 2 10 10 20
1 1
1 4
1 9
2 5
3 10
4 2
4 7
5 9
6 4
6 6
6 7
7 1
7 3
7 7
8 1
8 5
8 10
9 2
10 4
10 9      Sample Output 2 4
26
22
10
2
0
0
0
0
0       Sample Input 3 1000000000 1000000000 0      Sample Output 3 999999996000000004
0
0
0
0
0
0
0
0
0

Solution (Python):

from collections import defaultdict
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
 
h, w, n = [int(item) for item in input().split()]
blk_cnt = defaultdict(int) 
 
for i in range(n):
    a, b = [int(item) - 1 for item in input().split()]
    for j in range(-1, 2):
        for k in range(-1, 2):
            blk_cnt[(a + j, b + k)] += 1
ans = [0] * 10 
for key in blk_cnt.keys():
    if key[0] < 1 or key[1] < 1 or key[0] >= h-1 or key[1] >= w-1:
        continue
    ans[blk_cnt[key]] += 1
total = (w - 2) * (h - 2)
ans[0] = total - sum(ans)
for item in ans:
    print(item)

Solution (Python):
import sys
input = sys.stdin.readline

def main():
    h,w,n = map(int,input().split())
    dg = 10**10
    d = dict()

    def f(z):
        x,y = divmod(z,dg)
        if 2 <= x <= h-1 and 2 <= y <= w-1:
            return True
        else:
            False

    for i in range(n):
        a,b = map(int,input().split())
        
        if f((a-1)*dg + b-1):
            if (a-1)*dg + b-1 in d:
                d[(a-1)*dg + b-1] += 1
            else:
                d[(a-1)*dg + b-1] = 1
        
        if f((a-1)*dg + b):
            if (a-1)*dg + b in d:
                d[(a-1)*dg + b] += 1
            else:
                d[(a-1)*dg + b] = 1
        
        if f((a-1)*dg + b+1):
            if (a-1)*dg + b+1 in d:
                d[(a-1)*dg + b+1] += 1
            else:
                d[(a-1)*dg + b+1] = 1

        if f((a)*dg + b-1):
            if (a)*dg + b-1 in d:
                d[(a)*dg + b-1] += 1
            else:
                d[(a)*dg + b-1] = 1
        
        if f(a*dg + b):
            if a*dg + b in d:
                d[a*dg + b] += 1
            else:
                d[a*dg + b] = 1
        
        if f((a)*dg + b+1):
            if (a)*dg + b+1 in d:
                d[(a)*dg + b+1] += 1
            else:
                d[(a)*dg + b+1] = 1
        
        if f((a+1)*dg + b+1):
            if (a+1)*dg + b+1 in d:
                d[(a+1)*dg + b+1] += 1
            else:
                d[(a+1)*dg + b+1] = 1
        
        if f((a+1)*dg + b):
            if (a+1)*dg + b in d:
                d[(a+1)*dg + b] += 1
            else:
                d[(a+1)*dg + b] = 1
        
        if f((a+1)*dg + b-1):
            if (a+1)*dg + b-1 in d:
                d[(a+1)*dg + b-1] += 1
            else:
                d[(a+1)*dg + b-1] = 1
        
        
        
        
    res = [0]*10

    for e in d:
        res[d[e]] += 1

    res[0] = (h-2)*(w-2)-sum(res)

    for e in res:
        print(e)

if __name__ == "__main__":
    main()

Solution (Python):
h, w, n = map(int, input().split())
a = {tuple(map(int, input().split())) for _ in range(n)}

d = {}
c = [0] * 10

def next(x, y):
    ret = []
    for i in range(max(0, x-2), min(h-2, x+1)):
        for j in range(max(0, y-2), min(w-2, y+1)):
            ret.append((i, j))
    return ret

for x, y in a:
    x -= 1
    y -= 1
    for s, t in next(x, y):
        if (s, t) not in d:
            count = 0
            for i in range(3):
                for j in range(3):
                    if (s + i + 1, t + j + 1) in a:
                        count += 1
            d[(s, t)] = count
            c[count] += 1

c[0] = (h-2) * (w-2) - sum(c)

for x in c:
    print(x)

Solution (Python):
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    H,W,N=MI()
    B=set([])
    from collections import defaultdict
    used = defaultdict(int)
    ans=[0]*10
    
    for _ in range(N):
        a,b=MI()
        a-=1
        b-=1
        B.add((a,b))
        
    def cnt(i,j):
        if i+2<H and j+2<W:
            temp=0
            for di in range(3):
                for dj in range(3):
                    ii=i+di
                    jj=j+dj
                    if (ii,jj) in B:
                        temp+=1
            used[(i,j)]=1
            return temp
        return -1
    
    def se(i,j):
        for di in range(-2,1,1):
            for dj in range(-2,1,1):
                ii=i+di
                jj=j+dj
                if ii>=0 and jj>=0:
                    if not used[(ii,jj)]:
                        cc=cnt(ii,jj)
                        if cc!=-1:
                            
                            ans[cnt(ii,jj)]+=1
                        
    for k in B:
        i,j=k[0],k[1]
        se(i,j)
        
    S=sum(ans)
    ans[0]=(H-2)*(W-2) - S
    for i in range(10):
        print(ans[i])
                    

main()

Solution (Python):
import sys

h,w,n=map(int,input().split())
A = [map(int,input().split()) for _ in range(n)]

dict = {}
ans = [0]*10
ans[0] = (w-2)*(h-2)

for item in A:
    cord = list(item)

    
    upcand = []
    for i in range(cord[0]-1,cord[0]+2):
        for j in range(cord[1]-1,cord[1]+2):

            upcand.append([i,j])

    for cand in upcand:

        if 1 < cand[0] < h and 1 < cand[1] < w:

            dict[(cand[0],cand[1])] = dict.get((cand[0],cand[1]), 0) + 1

for v in dict.values():
    ans[v] += 1
    ans[0] -= 1

for i in ans:
    print(i)

Solution (Python):
import sys

h,w,n=map(int,input().split())
A = [map(int,input().split()) for _ in range(n)]

dict = {}
ans = [0]*10
ans[0] = (w-2)*(h-2)

for item in A:
    cord = list(item)

    
    upcand = []
    for i in range(cord[0]-1,cord[0]+2):
        for j in range(cord[1]-1,cord[1]+2):

            upcand.append([i,j])

    for cand in upcand:

        if 1 < cand[0] < h and 1 < cand[1] < w:

            dict[(cand[0],cand[1])] = dict.get((cand[0],cand[1]), 0) + 1

for k,v in dict.items():
    ans[v] += 1
    ans[0] -= 1

for i in ans:
    print(i)

Solution (Python):
import sys
from collections import Counter

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

H, W, N = lr()
pairs = []
for _ in range(N):
    a, b = lr()
    a -= 1; b -= 1
    for dh in [-2, -1, 0]:
        if a + dh < 0 or a + dh > H-3:
            continue
        for dw in [-2, -1, 0]:
            if b + dw < 0 or b + dw > W-3:
                continue
            pairs.append((a+dh, b+dw))

counter = Counter(pairs)
answer = [0] * 10
counter2 = Counter(counter.values())
for k, v in counter2.items():
    answer[k] = v

answer[0] = (H-2) * (W-2) - sum(answer)
print('\n'.join(map(str, answer)))

Solution (Python):
from collections import defaultdict, Counter

h, w, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

d = defaultdict(int)

for a, b in ab:
    for hi in range(a - 2, a + 1):
        for wi in range(b - 2, b + 1):
            if 1 <= hi <= h - 2 and 1 <= wi <= w - 2:
                d[(hi, wi)] += 1

c = Counter(d.values())

print((h - 2) * (w - 2) - sum(c.values()))

for i in range(1, 10):
    print(c[i])

Solution (Python):
from collections import defaultdict

h, w, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

d = defaultdict(int)

for a, b in ab:
    for hi in range(a - 2, a + 1):
        for wi in range(b - 2, b + 1):
            if 1 <= hi <= h - 2 and 1 <= wi <= w - 2:
                d[(hi, wi)] += 1

cnt = [0] * 10
for v in d.values():
    cnt[v] += 1

cnt[0] = (h - 2) * (w - 2) - sum(cnt[1:])
print(*cnt, sep="\n")

Solution (Python):
H, W, N = map(int, input().split())
d = {}

for i in range(N):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    for j in range(-1, 2):
        for k in range(-1, 2):
            if 1 <= a+j < H-1 and 1 <= b+k < W-1:
                if d.get((a+j, b+k)) is None:
                    d[(a+j, b+k)] = 0
                d[(a+j, b+k)] += 1


ans = [0] * 10
for v in d.values():
    ans[v] += 1
ans[0] = (H-2)*(W-2)-sum(ans[1:])

for i in range(10):
    print(ans[i])

Solution (Python):

import sys
from collections import Counter
INF = float("inf")

XX = (-2, -2, -2, -1, -1, -1, 0, 0, 0)
YY = (-2, -1, 0, -2, -1, 0, -2, -1, 0)


def solve(H: int, W: int, N: int, a: "List[int]", b: "List[int]"):
    counter = Counter()
    for aa, bb in zip(a, b):
        for x, y in zip(XX, YY):
            if aa+x < 1:
                continue
            elif aa+x+2 > H:
                continue
            elif bb+y < 1:
                continue
            elif bb+y+2 > W:
                continue
            counter[(aa+x, bb+y)] += 1
    ans = [0]*10
    for key, val in counter.items():
        ans[val] += 1

    ans[0] = (H-2)*(W-2) - sum(ans)
    print(*ans, sep="\n")
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  
    W = int(next(tokens))  
    N = int(next(tokens))  
    a = [int()] * (N)  
    b = [int()] * (N)  
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(H, W, N, a, b)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
input=sys.stdin.readline
h,w,n=map(int,input().split())
z=(h-2)*(w-2)
p=[]
for i in range(n):
    x,y=map(int,input().split())
    for j in range(3):
        for k in range(3):
            p.append([x+j-1,y+k-1])
p.sort(key=lambda x:(10**10)*x[0]+x[1])
n=len(p)
p.append([10**20,10**20])
ans=[0]*10
f=1
for i in range(n):
    if 2<=p[i][0]<=h-1 and 2<=p[i][1]<=w-1:
        if p[i]==p[i+1]:
            f+=1
        else:
            ans[f]+=1
            f=1
ans[0]=z-sum(ans)
for i in ans:
    print(i)

Solution (Python):

h,w,n=map(int,input().split())
dic={}
for  _ in range(n):
    a,b=map(int,input().split())
    for i in range(a-1,a+2):
        for j in range(b-1,b+2):
            if (i,j) in dic.keys():
                dic[(i,j)]+=1
            else:
                dic[(i,j)]=1
              
howmany=[0 for i in range(10)]
for some in dic.keys():
    a,b=some[0],some[1]
    if 2<=a<=h-1 and 2<=b<=w-1:
        howmany[dic[some]]+=1
J=(h-2)*(w-2)-sum(howmany)
print(J)
for i in range(1,10):
    print(howmany[i])

Solution (Python):
from collections import Counter
H,W,N = map(int,input().split())
ab = []
corner = []
countlist = [0 for i in range(10)]
for i in range(N):
    a,b = map(int,input().split())
    for h in range(-2,1):
        for w in range(-2,1):
            if 1 <= a+h <= H-2 and 1 <= b+w <= W-2:
                corner.append((a+h,b+w))
cc = Counter(corner)
clist = list(cc.values())
clistc = Counter(clist)
for k,v in clistc.items():
    countlist[k] += v
countlist[0] = (H-2)*(W-2) - sum(countlist)
for i in countlist:
    print(i)

Solution (Python):
from collections import Counter
H, W, N, *L = map(int, open(0).read().split())
dic = {}
for a, b in zip(*[iter(L)]*2):
  for i in range(a-2,a+1):
    for j in range(b-2,b+1):
      if 0<i and i+2<=H and 0<j and j+2<=W:
        dic[i*W+j] = dic.get(i*W+j,0)+1
c = Counter(dic.values())
ans = [(H-2)*(W-2)]+[0]*9
for k in c.keys():
  ans[k] = c[k]
  ans[0] -= c[k]
print('\n'.join(map(str,ans)))

Solution (Python):
H, W, N, *L = map(int, open(0).read().split())
dic = {}
for a, b in zip(*[iter(L)]*2):
  for i in range(a-2,a+1):
    for j in range(b-2,b+1):
      if 0<i and i+2<=H and 0<j and j+2<=W:
        dic[i*W+j] = dic.get(i*W+j,0)+1
ans = [0]*10
ans[0] = (W-2)*(H-2)
for k in dic.keys():
  ans[dic[k]] += 1
  ans[0] -= 1
print('\n'.join(map(str,ans)))

Solution (Python):
from collections import defaultdict
H, W, N, *L = map(int, open(0).read().split())
dic = defaultdict(int)
for a, b in zip(*[iter(L)]*2):
  for i in range(a-2,a+1):
    for j in range(b-2,b+1):
      if 0<i and i+2<=H and 0<j and j+2<=W:
        dic[(i,j)] += 1
ans = [0]*10
ans[0] = (W-2)*(H-2)
for k in dic.keys():
  ans[dic[k]] += 1
  ans[0] -= 1
print(*ans,sep='\n')

Solution (Python):
from collections import defaultdict
H, W, N, *L = map(int, open(0).read().split())
dic = defaultdict(int)
for a, b in zip(*[iter(L)]*2):
  for i in range(a-2,a+1):
    for j in range(b-2,b+1):
      if 0<i and i+2<=H and 0<j and j+2<=W:
        dic[(i,j)] += 1
ans = [0]*10
ans[0] = (W-2)*(H-2)
for k in dic.keys():
  ans[dic[k]] += 1
  ans[0] -= 1
print(*ans,sep='\n')

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



h, w, n = LI()
D = defaultdict(int)
for _ in range(n):
    a, b = LI()
    a -= 1; b -= 1;
    for i, j in product(range(a - 1, a + 2), range(b - 1, b + 2)):
        if 1 <= i < h - 1 and 1 <= j < w - 1:
            D[(i, j)] += 1


ans = [0] * 10
for k, v in D.items():
    ans[v] += 1



ans[0] = (h - 2) * (w - 2) - sum(ans)
print('\n'.join(list(map(str, ans))))

Solution (Python):
from collections import defaultdict

h, w, n = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(n)]
d = defaultdict(int)
L = [0]*10
L[0] = (h-2) * (w-2)
for a, b in AB:
  for i in range(-1, 2):
    for j in range(-1, 2):
      y, x = a+i, b+j
      if 1 < y < h and 1 < x < w:
        d[(y, x)] += 1
        L[d[(y, x)]] += 1
        L[d[(y, x)]-1] -= 1
print(*L, sep="\n")

Solution (Python):
H,W,N=map(int,input().split())
direc=[[0,0],[-1,0],[-2,0],[0,-1],[-1,-1],[-2,-1],[0,-2],[-1,-2],[-2,-2]]
dic={}
for i in range(N):
  h,w=map(int,input().split())
  for d in direc:
    if 1<=h+d[0]<=(H-2) and 1<=w+d[1]<=(W-2):
      l=(h+d[0],w+d[1])
      if l in dic:
        dic[l]=dic[l]+1
      else:
        dic[l]=1
A=list(dic.values())
print((H-2)*(W-2)-len(A))
for i in range(1,10):
  print(A.count(i))

Solution (Python):
H,W,N=map(int,input().split())
direc=[[0,0],[-1,0],[-2,0],[0,-1],[-1,-1],[-2,-1],[0,-2],[-1,-2],[-2,-2]]
dic={}
for i in range(N):
  h,w=map(int,input().split())
  for d in direc:
    if 1<=h+d[0]<=(H-2) and 1<=w+d[1]<=(W-2):
      l=(h+d[0],w+d[1])
      if l in dic:
        dic[l]=dic[l]+1
      else:
        dic[l]=1
A=list(dic.values())
print((H-2)*(W-2)-len(A))
for i in range(1,10):
  print(A.count(i))

Solution (Python):

from collections import Counter, defaultdict
from itertools import product
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(H: int, W: int, N: int, a: "List[int]", b: "List[int]"):
    d = defaultdict(int)
    for ai, bi in zip(a, b):
        for da, db in product((-1, 0, 1), repeat=2):
            aj = ai - 1 + da
            bj = bi - 1 + db
            if 1 <= aj <= H - 2 and 1 <= bj <= W - 2:
                d[aj, bj] += 1
    c = Counter(d.values())
    e = [c[i] for i in range(1, 10)]
    print((H - 2) * (W - 2) - sum(e))
    for ei in e:
        print(ei)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  
    W = int(next(tokens))  
    N = int(next(tokens))  
    a = [int()] * (N)  
    b = [int()] * (N)  
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(H, W, N, a, b)


if __name__ == '__main__':
    main()

Solution (Python):
H,W,N = map(int,input().split())
Nli=[0 for j in range(9*N)]
q=0
for k in range(N):
    a,b=map(int,input().split())
    for n in range(-1,2):
        for m in range(-1,2):
            if 0<=a-2-m<H-2 and 0<=b-2-n<W-2:
                Nli[q]=(b-n)*(H)+(a-m)
                q+=1
del Nli[q:]
import collections
s = collections.Counter(Nli)
v = list(s.values())
print((H-2)*(W-2)-len(set(Nli)))
for k in range(1,10):
    print(v.count(k))

Solution (Python):
H,W,N = map(int,input().split())
Nli=[]
for k in range(N):
    a,b=map(int,input().split())
    for n in range(-1,2):
        for m in range(-1,2):
            if 0<=a-2-m<H-2 and 0<=b-2-n<W-2:
                Nli.append((b-n)*(H)+(a-m))
import collections
s = collections.Counter(Nli)
v = list(s.values())
print((H-2)*(W-2)-len(set(Nli)))
for k in range(1,10):
    print(v.count(k))

Solution (Python):
H,W,N = map(int,input().split())
Nli=[]
for k in range(N):
    a,b=map(int,input().split())
    for n in range(-1,2):
        for m in range(-1,2):
            if 0<=a-2-m<H-2 and 0<=b-2-n<W-2:
                Nli.append((b-n)*(H)+(a-m))
import collections
s = collections.Counter(Nli)
v = list(s.values())
print((H-2)*(W-2)-len(set(Nli)))
for k in range(1,10):
    print(v.count(k))

Solution (Python):
from collections import *
h,w,n = map(int,input().split())
dic = defaultdict(int)
for _ in range(n):
  a,b = map(int,input().split())
  for i in range(9):
    dic[a - i //3,b - i % 3] += 1
ans =[0]*10
for i, j in dic:
  ans[dic[i,j]] += h-1 > i > 0 < j < w -1
ans[0] = (h -2)*(w-2) - sum(ans)
for item in ans:
  print(item)

Solution (Python):
import sys
input = sys.stdin.buffer.readline
from collections import defaultdict

def main():
    H,W,N = map(int,input().split())
    d = defaultdict(int)
    for i in range(N):
        a,b = map(int,input().split())
        a -= 1
        b -= 1
        for x in range(3):
            for y in range(3):
                na,nb = a-x,b-y
                if (0 <= na < H-2 and 0 <= nb < W-2):
                    d[na*W+nb] += 1
    
    d = list(d.values())
    ans = (H-2)*(W-2)-len(d)
    print(ans)
    for i in range(9):
        i += 1
        print(d.count(i))

if __name__ == "__main__":
    main()

Solution (Python):
"""
l = input().split(" ")
w = int(l[0])
h = int(l[1])
n = int(l[2])

array = [[0 for i in range(h)] for j in range(w)]

for i in range(n):
	l = input().split(" ")
	x = int(l[0]) - 1
	y = int(l[1]) - 1
	for i in range(3):
		for j in range(3):
			if x+j-1 >=0 and x+j-1<w and y+i-1 >=0 and y+i-1<h:
				array[x+j-1][y+i-1] += 1

ans = [0 for i in range(10)]

for i in range(h-2):
	for j in range(w-2):
		ans[array[j+1][i+1]] += 1

for a in ans:
	print(a)

"""

l = input().split(" ")
w = int(l[0])
h = int(l[1])
n = int(l[2])

array = dict()

for i in range(n):
	l = input().split(" ")
	x = int(l[0])
	y = int(l[1])
	for i in range(3):
		if y-i < 1 or y-i > h-2:
			continue
		for j in range(3):
			if x-j < 1 or x-j > w-2:
				continue
			if (x-j, y-i) in array:
				array[(x-j, y-i)] +=1
			else:
				array[(x-j, y-i)] = 1

ans = [0] * 10
ans[0] = (h-2) * (w-2)
 
for i in array:
    ans[array[i]] += 1
    ans[0] -= 1

for i in range(10):
    print(ans[i])

Solution (Python):
f=lambda:map(int,input().split())
h,w,n = f()

d={}
while n:
 n-=1
 x,y=f()
 for i in range(9):
     a=(x+i%3,y+i//3)
     d[a]=d.get(a,0)+(h>=a[0]>2<a[1]<=w)

c=[list(d.values()).count(i+1)for i in range(9)]

print((h-2)*(w-2)-sum(c))
for i in range(9):
    print(c[i])

Solution (Python):
h,w,n=map(int,input().split())
d=dict()
def change(a,b):
    global h,w,d
    if 1<=a<h-1 and 1<=b<w-1:
        if (a,b) in d:
            d[(a,b)]+=1
        else:
            d[(a,b)]=1
for i in range(n):
    a,b=map(int,input().split())
    a-=1
    b-=1
    for j in range(3):
        for k in range(3):
            change(a+j-1,b+k-1)
ans=[0]*10
ans[0]=(h-2)*(w-2)

for i in d:
    ans[d[i]]+=1
    ans[0]-=1
for i in range(10):
    print(ans[i])

Solution (Python):
h,w,n=map(int,input().split())
d=dict()
def change(a,b):
    global h,w,d
    if 1<=a<h-1 and 1<=b<w-1:
        if (a,b) in d:
            d[(a,b)]+=1
        else:
            d[(a,b)]=1
for i in range(n):
    a,b=map(int,input().split())
    a-=1
    b-=1
    change(a,b)
    change(a-1,b-1)
    change(a-1,b+1)
    change(a+1,b-1)
    change(a+1,b+1)
    change(a-1,b)
    change(a+1,b)
    change(a,b-1)
    change(a,b+1)
ans=[0]*10
ans[0]=(h-2)*(w-2)

for i in d:
    ans[d[i]]+=1
    ans[0]-=1
for i in range(10):
    print(ans[i])

Solution (Python):
import sys
sys.stdin.readline

def main():
    H, W, N = map(int, input().split())
    AB = [tuple(map(int, input().split())) for _ in range(N)]
    X = [-1, -1, -1, 0, 0, 0, 1, 1, 1]
    Y = [-1, 0, 1, -1, 0, 1, -1, 0, 1]
    XY = list(zip(X, Y))
    S = {}
    for a, b in AB:
        for x, y in XY:
            k = (a+x, b+y)
            S.setdefault(k, 0)
            S[k] += 1
    ans = [0] * 10
    for (x, y), v in S.items():
        if 1 < x < H and 1 < y < W:
            ans[v] += 1
    ans[0] = (H-2)*(W-2)-sum(ans[1:])
    print(*ans, sep="\n")

if __name__ == "__main__":
    main()

Solution (Python):
import sys
input = sys.stdin.buffer.readline

from collections import defaultdict

H, W, N = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

counter = defaultdict(int)
for a, b in AB:
  for aa in range(a - 1, a + 2):
    for bb in range(b - 1, b + 2):
      if 2 <= aa <= H - 1 and 2 <= bb <= W - 1:
        counter[(aa, bb)] += 1

answer = [0] * (10)
for (x, y), n in list(counter.items()):
  if n:
    answer[n] += 1
answer[0] = (H - 2) * (W - 2)
for i in range(1, 10):
  answer[0] -= answer[i]
  
for a in answer:
  print(a)

Solution (Python):
import sys
input = sys.stdin.buffer.readline

from collections import defaultdict

H, W, N = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
SIZE = 10 ** 9 + 1

counter = defaultdict(int)
for a, b in AB:
  for aa in range(a - 1, a + 2):
    for bb in range(b - 1, b + 2):
      if 2 <= aa <= H - 1 and 2 <= bb <= W - 1:
        counter[aa * SIZE + bb] += 1

answer = [0] * (10)
for x, n in list(counter.items()):
  if n:
    answer[n] += 1
answer[0] = (H - 2) * (W - 2)
for i in range(1, 10):
  answer[0] -= answer[i]
  
for a in answer:
  print(a)

Solution (Python):
dx = [-1,-1,-1,0,0,1,1,1,0]
dy = [-1,0,1,-1,1,-1,0,1,0]
H,W,N = map(int,input().split())
from collections import defaultdict, Counter
d = defaultdict(int)
for i in range(N):
    a,b = map(int,input().split())
    for j in range(9):
        A = a + dy[j]
        B = b + dx[j]
        f = 0
        if 2 <= A <= H-1:
            if 2 <= B <= W-1:
                f = 1
        if f == 1:
            d[(A,B)] += 1
s = 0
c = Counter(d.values())
for i in range(1,10):
    s += c[i]
c[0] = (H-2)*(W-2) - s
for i in range(10):
    print(c[i])

Solution (Python):
from itertools import product
from collections import defaultdict, Counter
import sys
input = sys.stdin.readline
h,w,n = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
pls = defaultdict(int)
for x,y in a:
  for arx,ary in product(list(range(x-1,x+2)),list(range(y-1,y+2))):
    if 2<=arx<=h-1 and 2<=ary<=w-1:
      pls[(arx,ary)] += 1
c = Counter(pls.values())
print((h-2)*(w-2)-sum(c.values()))
for i in range(1,10):
  print(c[i])

Solution (Python):
import sys
input = sys.stdin.readline
from collections import Counter
h,w,n=map(int,input().split())
c=Counter()
for _ in range(n):
    b,a=map(int,input().split())
    for i in [-1,0,1]:
        for j in [-1,0,1]:
            if 2<=a+i<w and 2<=b+j<h:
                c[a+i,b+j]+=1

c2=Counter(c.values())
print((h-2)*(w-2)-sum(c2.values()))
for i in range(1,10):
    print(c2[i])

Solution (Python):




import collections
H, W, N = map(int, input().split(' '))

point_frq_dict = collections.defaultdict(int)
for _ in range(N):
    a, b = map(int, input().split(' '))
    for i in range(3):
        for j in range(3):
            if 0 < a-i < H-1 and 0 < b-j < W-1:
                point_frq_dict[(a-i, b-j)] += 1

ans = [0 for _ in range(10)]
n = 0
for frq in point_frq_dict.values():
    ans[frq] += 1

ans[0] = (H-2)*(W-2) - sum(ans)
for a in ans:
    print(a)

Solution (Python):
h,w,n = map(int, input().split())


black = dict()


search = set()

for i in range(n):
    a,b = map(int, input().split())
    a-=1
    b-=1
    for x in [-1,0,1]:
        for y in [-1,0,1]:
            if 1<=a+y<h-1 and 1<=b+x<w-1:
                search.add((a+y,b+x))  
    try:
        black[a][b]=1
    except:
        black[a]=dict()
        black[a][b]=1


ans = [0]*10

for a,b in search:
    p = 0
    for y in [-1,0,1]:
        for x in [-1,0,1]:
            try:
                if black[a+y][b+x]==1:
                    p+=1
            except:
                continue
    ans[p]+=1
ans[0]=(h-2)*(w-2)-sum(ans[1:])

for a in ans:
    print(a)

Solution (Python):
from collections import defaultdict
import sys
input = sys.stdin.readline

H,W,N = map(int,input().split())
D = defaultdict(bool)
B = []

for _ in range(N):
    a,b = map(lambda x: int(x)-1,input().split())
    D[(a,b)] = True
    B.append((a,b))

ans = [0 for _ in range(10)]

for a,b in B:
    for i in range(9):
        ix,iy = divmod(i,3)
        if a-ix<0 or b-iy<0:
            continue
        black_count = 0
        for j in range(9):
            jx,jy = divmod(j,3)
            if H<=a-ix+jx or W<=b-iy+jy:
                break
            if (a-ix+jx,b-iy+jy) in D:
                if -iy+jy<0 or (-iy+jy==0 and -ix+jx<0):
                    break
                black_count += 1
        else:
            ans[black_count] += 1

ans[0] = (H-2)*(W-2)-sum(ans)
print(*ans,sep='\n')

Solution (Python):


import sys
from collections import defaultdict, Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

H, W, N = MAP()
D = defaultdict(int)


for _ in range(N):
    a, b = MAP()
    for i in range(max(a-2, 1), min(a+1, H-1)):
        for j in range(max(b-2, 1), min(b+1, W-1)):
            D[(i, j)] += 1

C = Counter(D.values())
total = (H-2) * (W-2)

print(total - sum(C.values()))
for i in range(1, 10):
    print(C[i])

Solution (Python):
H, W, N = list(map(int, input().split()))
D = []
for _ in range(N):
    a, b = list(map(int, input().split()))
    for dy in (-1, 0, +1):
        y = a + dy
        if y<=1 or y>=H: continue
        for dx in (-1, 0, +1):
            x = b + dx
            if x<=1 or x>=W: continue
            D.append((x,y))

D = sorted(D)

i = 0
M = len(D)
ans = [0]*10
while i<M:
    n = 1
    d = D[i]
    while i+n<M and D[i+n]==d: n+=1
    ans[n] += 1
    i+=n

ans[0] = (H-2)*(W-2) - sum(ans)
print(*ans, sep='\n')

Solution (Python):
h, w, n = map(int, input().split())

dic = {}

for i in range(n):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    for i in range(-1, 2):
        for j in range(-1, 2):
            if a + i <= 0 or a + i >= h - 1 or b + j <= 0 or b + j >= w - 1:
                continue
            if (a+i, b+j) in dic:
                dic[(a+i, b+j)] += 1
            else:
                dic[(a+i, b+j)] = 1

count = [0]*10
for i in dic.values():
    count[i] += 1
count[0] = (h-2)*(w-2)-sum(count)
for i in range(10):
    print(count[i])

Solution (Python):
import numpy as np

import collections
import sys
input = sys.stdin.readline

H,W,N = map(int,input().split())

ab = []

eff = collections.defaultdict(int)

for i in range(N):
    temp = list(map(int,input().split()))
    ab.append(temp)
    for j in range(3):
        for k in range(3):
            if (temp[0]-j >= 1) & (temp[0]-j <= H-2):
                if (temp[1]-k >= 1) & (temp[1]-k <= W-2):
                    eff[(temp[0]-j,temp[1]-k)] += 1

count = collections.Counter(eff.values())

count0 = (H-2) * (W-2) - sum(count.values())

print(count0)
for i in range(1,10):
    if i in count:
        print(count[i])
    else:
        print(0)

Solution (Python):
def main():
    from sys import stdin
    input = stdin.readline
    h, w, n = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in [0]*n]

    ans = [0]*10
    d = {}

    for a, b in ab:
        for j in range(-1, 2):
            for k in range(-1, 2):
                d[(a+j, b+k)] = d.get((a+j, b+k), 0)+1

    for (i, j), k in d.items():
        if 2 <= i < h and 2 <= j < w:
            ans[k] += 1

    print((h-2)*(w-2)-sum(ans))
    for i in ans[1:]:
        print(i)


main()

Solution (Python):
h,w,n = map(int,input().split())

from collections import defaultdict
dic = defaultdict(int)
for _ in range(n):
   a,b = map(int,input().split())
   a -= 1
   b -= 1
   for aa in range(a-1, a+2):
      for bb in range(b-1, b+2):
         if 1 <= aa <= h-2 and 1 <= bb <= w-2:
            dic[(aa,bb)] += 1
ans = [0 for i in range(10)]
for i in dic.values():
   ans[i] += 1

ans[0] = (h-2)*(w-2) - sum([ans[i] for i in range(1,10)])

for anss in ans:
   print(anss)

Solution (Python):
h,w,n = map(int, input().split())

from collections import Counter
d = []

for _ in range(n):
    a,b = map(int,input().split())
    for k in range(3):
        for l in range(3):
            if 0 < a-k < h-1 and 0 < b-l < w-1:
                d.append((a-k,b-l))

dd = Counter(d)
ddd = list(dd.values())

ans = [0]*10

for i in range(1,10):
    ans[i] = ddd.count(i)

ans[0] = (h-2)*(w-2) - sum(ans)

for x in ans:
    print(x)

Solution (Python):
H, W, N = list(map(int, input().split()))
ans = {}
for i in range(N):
  a, b = list(map(int, input().split()))
  for j in range(-1, 2):
    for k in range(-1, 2):
      if (a+j)>=2 and (b+k)>=2 and (a+j)<=(H-1) and (b+k)<=(W-1):
        key = str(a+j) + "_" + str(b+k)
        ans[key] = ans.get(key, 0) + 1
ans_value = list(ans.values())
ans_n0 = 0
for i in range(1, 10):
  ans_n0 = ans_n0 + ans_value.count(i)
print((H-2)*(W-2)-ans_n0)
for i in range(1, 10):
  print(ans_value.count(i))