시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 256 MB666100.000%

문제

You are given an $H \times W$ grid. The square at the top-left corner is indexed $(0, 0)$, and the square at the bottom-right corner is indexed by $(H-1, W-1)$.

$N$ squares $(x_1, y_1), (x_2, y_2), \ldots, (x_N, y_N)$ are painted black, and all other squares are painted white.

Let the shortest distance between white squares $A$ and $B$ be the minimum number of moves required to reach $B$ from $A$ visiting only white squares, where one can travel to an adjacent square sharing a side (up, down, left or right) in one move.

Since there are $H \times W - N$ white squares in total, there are $C_{H \times W - N}^2$ ways to choose two of the white squares. For each of these $C_{H \times W - N}^2$ ways, find the shortest distance between the chosen squares, then find the sum of all those distances, modulo $1\,000\,000\,007=10^9+7$.

입력

Input is given in the following format:

$H$ $W$

$N$

$x_1$ $y_1$

$x_2$ $y_2$

$\ldots$

$x_N$ $y_N$

출력

Print the sum of the shortest distances modulo $10^9+7$.

제한

$1 \leq H, W \leq 10^6$, $1 \leq N \leq 30$, $0 \leq x_i \leq H-1$, $0 \leq y_i \leq W-1$. If $i \neq j$, then either $x_i \neq x_j$ or $y_i \neq y_j$. It is guaranteed that there is at least one white square. For every pair of white squares $A$ and $B$, it is possible to reach $B$ from $A$ visiting only white squares.

예제 입력 1

2 3
1
1 1

예제 출력 1

20

예제 입력 2

2 3
1
1 2

예제 출력 2

16

예제 입력 3

3 3
1
1 1

예제 출력 3

64

예제 입력 4

4 4
4
0 1
1 1
2 1
2 2

예제 출력 4

268

예제 입력 5

1000000 1000000
1
0 0

예제 출력 5

333211937

힌트

In Sample 1, we have the next grid ('.' denotes white square, '!' --- black square):

...
.!.

We assign alphabet to white squares, like below.

ABC
D!E

So we get (here $dist(A,B)$ is the shortest distance between $A$ and $B$):

$dist(A, B) = 1$, $dist(A, C) = 2$, $dist(A, D) = 1$, $dist(A, E) = 3$, $dist(B, C) = 1$, $dist(B, D) = 2$, $dist(B, E) = 2$, $dist(C, D) = 3$, $dist(C, E) = 1$, $dist(D, E) = 4$, and sum of those is $20$.

In Sample 2, we assign alphabet to white squares, like below.

ABC
DE!

So we get:

$dist(A, B) = 1$, $dist(A, C) = 2$, $dist(A, D) = 1$, $dist(A, E) = 2$, $dist(B, C) = 1$, $dist(B, D) = 2$, $dist(B, E) = 1$, $dist(C, D) = 3$, $dist(C, E) = 2$, $dist(D, E) = 1$, and sum of those is $16$.