Simple APSP Problem

아직 제출이 없습니다시간 제한3초메모리 제한256 MB

문제

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

NN squares (x_1,y_1),(x_2,y_2),,(x_N,y_N)(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 AA and BB be the minimum number of moves required to reach BB from AA 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×WNH \times W - N white squares in total, there are C_H×WN2C\_{H \times W - N}^2 ways to choose two of the white squares. For each of these C_H×WN2C\_{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=109+71\\,000\\,000\\,007=10^9+7.

입력

Input is given in the following format:

HH WW

NN

x_1x\_1 y_1y\_1

x_2x\_2 y_2y\_2

\ldots

x_Nx\_N y_Ny\_N

출력

Print the sum of the shortest distances modulo 109+710^9+7.

제한

1H,W1061 \leq H, W \leq 10^6, 1N301 \leq N \leq 30, 0x_iH10 \leq x\_i \leq H-1, 0y_iW10 \leq y\_i \leq W-1. If iji \neq j, then either x_ix_jx\_i \neq x\_j or y_iy_jy\_i \neq y\_j. It is guaranteed that there is at least one white square. For every pair of white squares AA and BB, it is possible to reach BB from AA visiting only white squares.

힌트

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)dist(A,B) is the shortest distance between AA and BB):

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

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

ABC
DE!

So we get:

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