output_description: Print the sum of the shortest distances, modulo 10^9+7.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      H W
      N
      x_1 y_1
      x_2 y_2
      :
      x_N y_N
attempt: from collections import deque
  
  mod = 10**9 + 7
  h, w = map(int, input().split())
  n = int(input())
  
  ans = 0
  
  black = []
  row = [0] * h
  column = [0] * w
  for _ in range(n):
      x, y = map(int, input().split())
      row[x] += 1
      column[y] += 1
      black.append([x, y])
  
  
  cnt = 0
  top = 0
  bottom = h * w - n
  area = []
  for i in range(h):
      if row[i] == 0:
          cnt += 1
          if i != h - 1 and row[i + 1] == 0:
              top += w
              bottom -= w
              ans += top * bottom
              ans %= mod
          else:
              area.append([cnt for _ in range(w)])
      else:
          top += w - row[i]
          bottom -= w - row[i]
          area.append([1 for _ in range(w)])
          for x, y in black:
              if x == i:
                  area[-1][y] = 0
          cnt = 0
  
  R = len(area)
  
  cnt = 0
  left = 0
  right = h * w - n
  area2 = []
  for j in range(w):
      if column[j] == 0:
          cnt += 1
          if j != w - 1 and column[j + 1] == 0:
              left += h
              right -= h
              ans += left * right
              ans %= mod
          else:
              area2.append([cnt * area[i][j] for i in range(R)])
      else:
          left += w - column[j]
          right -= w - column[j]
          area2.append([area[i][j] for i in range(R)])
          cnt = 0
  
  C = len(area2)
  vec = [[1, 0], [0, 1], [-1, 0], [0, -1]]
  
  
  def bfs(p, q):
      dist = [[10**9 for _ in range(R)] for __ in range(C)]
      visited = [[False for _ in range(R)] for __ in range(C)]
      dist[p][q] = 0
      visited[p][q] = True
      q = deque([(p, q)])
      while q:
          x, y = q.popleft()
          for dx, dy in vec:
              if 0 <= x + dx < C and 0 <= y + dy < R and area2[x + dx][y + dy] != 0:
                  if not visited[x + dx][y + dy]:
                      dist[x + dx][y + dy] = dist[x][y] + 1
                      visited[x + dx][y + dy] = True
                      q.append((x + dx, y + dy))
      return dist
  
  
  ans2 = 0
  
  for i in range(C):
      for j in range(R):
          d = bfs(i, j)
          for k in range(C):
              for l in range(R):
                  ans2 += area2[i][j] * area2[k][l] * d[k][l]
                  ans2 %= mod
  
  ans2 *= pow(2, mod - 2, mod)
  
  print((ans + ans2) % mod)
  
problem_description: Statement
  
  You are given an H \times W grid. The square at the top-left corner will be
  represented by (0, 0), and the square at the bottom-right corner will be
  represented by (H-1, W-1).
  
  Of those squares, N squares (x_1, y_1), (x_2, y_2), ..., (x_N, y_N) are
  painted black, and the 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 × W - N white squares in total, there are _{(H×W-N)}C_2 ways
  to choose two of the white squares.
  
  For each of these _{(H×W-N)}C_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.
samples: [{"input": "2 3\n    1\n    1 1", "output": "20\n    \n\nWe have the following grid (`.`: a white square, `#`: a black square).\n\n    \n    \n    ...\n    .#.\n    \n\nLet us assign a letter to each white square as follows:\n\n    \n    \n    ABC\n    D#E\n    \n\nThen, we have:\n\n  * dist(A, B) = 1\n  * dist(A, C) = 2\n  * dist(A, D) = 1\n  * dist(A, E) = 3\n  * dist(B, C) = 1\n  * dist(B, D) = 2\n  * dist(B, E) = 2\n  * dist(C, D) = 3\n  * dist(C, E) = 1\n  * dist(D, E) = 4\n\nwhere dist(A, B) is the shortest distance between A and B. The sum of these\ndistances is 20.\n\n* * *"}, {"input": "2 3\n    1\n    1 2", "output": "16\n    \n\nLet us assign a letter to each white square as follows:\n\n    \n    \n    ABC\n    DE#\n    \n\nThen, we have:\n\n  * dist(A, B) = 1\n  * dist(A, C) = 2\n  * dist(A, D) = 1\n  * dist(A, E) = 2\n  * dist(B, C) = 1\n  * dist(B, D) = 2\n  * dist(B, E) = 1\n  * dist(C, D) = 3\n  * dist(C, E) = 2\n  * dist(D, E) = 1\n\nThe sum of these distances is 16.\n\n* * *"}, {"input": "3 3\n    1\n    1 1", "output": "64\n    \n\n* * *"}, {"input": "4 4\n    4\n    0 1\n    1 1\n    2 1\n    2 2", "output": "268\n    \n\n* * *"}, {"input": "1000000 1000000\n    1\n    0 0", "output": "333211937"}]