题目描述
Problem Description
JOI has decided to plan a sightseeing tour in a city called Super Metropolis in the country of IOI.
The Super Metropolis is divided into a grid by $ W $ straight roads running north-south and $ H $ straight roads running east-west.
The $ W $ north-south roads are numbered from 1 to $ W $ from west to east. The $ H $ east-west roads are numbered from 1 to $ H $ from south to north. The intersection of the $ i $-th north-south road and the $ j $-th east-west road is represented as $ (i, j) $.
Furthermore, as shown in the figure below, each intersection has a road to the northeast intersection (except for the intersections on the northernmost and easternmost roads). Additionally, there is also a road to the southwest intersection (except for the intersections on the southernmost and westernmost roads). That is, from intersection $ (i, j) $, you can travel to intersections $ (i - 1, j) $, $ (i + 1, j) $, $ (i, j - 1) $, and $ (i, j + 1) $ using a single road if they exist. In addition, you can also travel to intersections $ (i - 1, j - 1) $ and $ (i + 1, j + 1) $ using a single road if they exist.

JOI has already decided the order in which to visit $ N $ sightseeing spots for the tour. The $ i $-th ($1 \leq i \leq N$) sightseeing spot to visit is located at intersection $ (X_i, Y_i) $. JOI wants to minimize the total number of roads he must travel to visit the sightseeing spots in the predetermined order. Write a program to find the minimum total number of roads that must be traveled to visit the sightseeing spots in the given order.
Note that the tour starts at intersection $ (X_1, Y_1) $. Also, JOI must not move outside the Super Metropolis during the tour. JOI can also pass through intersections with sightseeing spots without visiting them.
(Added after the preliminary competition) Additional note on the "total number of roads": JOI can travel the same road more than once during the tour. In such cases, the "total number of roads" should count the road for each time it is traveled.
Input Format
The input consists of $ 1 + N $ lines.
The first line contains three integers $ W, H, N $ ($2 \leq W \leq 10,000$, $2 \leq H \leq 10,000$, $1 \leq N \leq 1,000$) separated by spaces.
The next $ N $ lines contain two integers $ X_i, Y_i $ ($1 \leq X_i \leq W$, $1 \leq Y_i \leq H$) separated by spaces, representing the intersection $ (X_i, Y_i) $ where the $ i $-th sightseeing spot is located.
Output Format
Output the minimum total number of roads that must be traveled to visit the sightseeing spots in order on a single line.
Sample Input and Output
Sample Input #1
4 3 3
1 1
3 3
4 1
Sample Output #1
5
Sample Input #2
4 3 5
1 3
4 3
2 2
2 2
1 3
Sample Output #2
7
Notes/Hints
Sample Explanation 1
In sample input/output #1, for example, visiting intersections in the order $ (1, 1) $, $ (2, 2) $, $ (3, 3) $, $ (3, 2) $, $ (4, 2) $, $ (4, 1) $ is sufficient.
Sample Explanation 2
In sample input/output #2, it is possible to visit the same intersection multiple times, as shown.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分