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 in C# (Mono 4.6.2.0) (judge verdict: Time Limit Exceeded)

using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using Enu = System.Linq.Enumerable;

public class Program
{
    static readonly long Big = (long)1e9;
    
    public void Solve()
    {
        int H = Reader.Int(), W = Reader.Int(), N = Reader.Int();
        var sw = Stopwatch.StartNew();
        var table = Reader.IntTable(N);
        var set = new SkipListSet();
        var black = new SkipListSet();

        var ans = new long[10];
        ans[0] = (long)(H - 2) * (W - 2);
        Func<int, int, bool> IsInside = (r, c) => r >= 0 && r < H && c >= 0 && c < W;

        foreach (var t in table)
        {
            black.Add(--t[0] * Big + --t[1]);
            for (int dr = -2; dr <= 0; dr++)
                for (int dc = -2; dc <= 0; dc++)
                    if (IsInside(t[0] + dr, t[1] + dc))
                        set.Add((t[0] + dr) * Big + t[1] + dc);
        }
        var node = set.Head;
        for (int i = 0; i < set.Count; i++)
        {
            node = node.Next[0];
            long mask = node.Val;
            long r = mask / Big, c = mask % Big;
            if (r + 3 <= H && c + 3 <= W)
            {
                int count = 0;
                for (int dr = 0; dr < 3; dr++)
                    for (int dc = 0; dc < 3; dc++)
                        if (black.Contains((r + dr) * Big + c + dc))
                            count++;
                ans[0]--;
                ans[count]++;
            }
        }

        Console.WriteLine(string.Join("\n", ans));
    }

    public class SkipListSet
    {
        public class Node
        {
            public long Val;
            public Node[] Next;
            public Node(long val, int height)
            {
                Val = val;
                Next = new Node[height + 1];
            }
        }
        public class XorShift
        {
            uint m = 2463534242;
            public uint Next() { m = m ^ m << 13; m = m ^ m >> 17; return m = m ^ m << 5; }
        }

        public int Count { get; private set; }

        static readonly int MaxHeight = 17;
        public Node Head;
        XorShift random = new XorShift();
        Node[] Ltmp;

        public SkipListSet()
        {
            Ltmp = new Node[MaxHeight + 1];
            Head = new Node(long.MinValue, MaxHeight);
            var InfNode = new Node(long.MaxValue, MaxHeight);
            for (int h = 0; h <= MaxHeight; h++)
                Head.Next[h] = InfNode;
        }

        public bool Add(long val)
        {
            Node L = Head;
            for (int h = MaxHeight; h >= 0; h--)
            {
                while (val >= L.Next[h].Val) L = L.Next[h];
                Ltmp[h] = L;
            }
            if (val == L.Val) return false;
            int height = RightmostBitIndex32((int)random.Next() | 1 << MaxHeight);
            var node = new Node(val, height);
            for (; height >= 0; height--)
            {
                node.Next[height] = Ltmp[height].Next[height];
                Ltmp[height].Next[height] = node;
            }
            Count++;
            return true;
        }

        public bool Contains(long val)
        {
            var L = Head;
            for (int h = MaxHeight; h >= 0; h--)
            {
                while (val >= L.Next[h].Val) L = L.Next[h];
                if (L.Val == val) return true;
            }
            return false;
        }

        int RightmostBitIndex32(int x)
        {
            return BitCount32((x & -x) - 1);
        }
        int BitCount32(int x)
        {
            x -= x >> 1 & 0x55555555;
            x = (x & 0x33333333) + (x >> 2 & 0x33333333);
            return ((x + (x >> 4) & 0x0f0f0f0f) * 0x01010101) >> 24;
        }
    }

}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    static string[] Split(string s) { return s.Split(separator, op); }
    static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}