p02128 Light
Problem

There are $ N $ streetlights on a two-dimensional square of $ W \ times H $.
Gaccho wants to start with $ (1,1) $ and go to $ (W, H) $.
Gaccho is afraid of dark places, so he only wants to walk in the squares that are brightened by the streetlights.
Initially, all streetlights only brighten the squares with the streetlights.
So, Gaccho decided to set the cost $ r_i $ for his favorite streetlight $ i $. There may be street lights for which no cost is set.
By consuming the cost $ r_i $, the streetlight $ i $ can brighten the range within $ r_i $ in Manhattan distance around the streetlight. However, the cost is a positive integer.
Gaccho can move to the adjacent square in either the up, down, left, or right direction.
Gaccho decided to set the total value of $ r_i $ to be the minimum. Find the total value at that time.


The Manhattan distance between two points $ (a, b) $ and $ (c, d) $ is represented by $ | a−c | $ + $ | b−d | $.

Constraints

The input satisfies the following conditions.

* $ 1 \ leq W \ leq 500 $
* $ 1 \ leq H \ leq 500 $
* $ 1 \ leq N \ leq 100 $
* $ 1 \ leq N \ leq W \ times H $
* $ 1 \ leq $$ x_i $$ \ leq W $
* $ 1 \ leq $$ y_i $$ \ leq H $
* There are no multiple streetlights at the same coordinates

Input

The input is given in the following format.


$ W $ $ H $ $ N $
$ x_1 $ $ y_1 $
...
$ x_N $ $ y_N $


All inputs are given as integers.
$ W $, $ H $, and $ N $ are given on the first line, separated by blanks.
In the following $ N $ line, the coordinates $ ($$ x_i $, $ y_i $$) $ of the streetlight $ i $ are given, separated by blanks.

Output

Output the minimum value of the total value of $ r_i $ on one line.

Examples

Input

10 10 1
6 6


Output

10


Input

5 10 3
3 9
2 8
5 1


Output

8


Input

1 1 1
1 1


Output

0
```python
import heapq
class point:
    def __init__(self, total, use, place):
        self.total = total
        self.use = use
        self.place = place

    def __lt__(self, other):
        return self.total < other.total or (self.total == other.total and self.use > self.use)


w, h, n = map(int, input().split())
if w == h == 1:
    print(0)
    exit()
lights = [list(map(int, input().split())) for _ in range(n)]
que = []
mins = []
for i, j in enumerate(lights):
    dis = j[0] + j[1] - 2
    heapq.heappush(que, point(dis, dis, i))
    mins.append(point(dis, dis, i))
ans = 100000
while que:
    top = heapq.heappop(que)
    ans = min(ans, top.total + max(0, abs(w - lights[top.place][0]) + abs(h - lights[top.place][1]) - top.use))
    for i in range(len(lights)):
        dis = abs(lights[top.place][0] - lights[i][0]) + abs(lights[top.place][1] - lights[i][1]) - 1
        use = max(0, dis - top.use)
        total = top.total + use
        new = point(total, use, i)
        if mins[i] > new:
            mins[i] = new
            heapq.heappush(que, new)
print(ans)

```