Monument Tour#9689

Monument Tour

1 second
128 megabytes
Easy

A tour operator proposes itineraries consisting of visits to monuments and museums in Paris, which is modeled as a rectangular grid. The tour operates as follows: the bus enters the city from the west (along any eastbound street) and travels eastward across the city. Whenever necessary, it may make a left or right turn to visit a monument, after which it must return to the same eastbound street it originally entered on. This process continues until the bus exits the city on the east side.

An example tour in a 6 \times 5 grid city is illustrated in the figure above. In this example, the bus enters the city at coordinate (with defined as the northwest corner of the city). It first visits the monument at , which lies directly on the main road. The bus then makes a left turn to visit the monument at , returns to the main road, and continues eastward. Next, it makes a right turn to visit the monument at , returns again to the main road, visits the monument at (also located on the main road), and finally exits the city at coordinate .

The tour operator assumes that traversing one city block costs 1 unit of gas. For the example above, the total cost is therefore 5 + 2 × 2 + 2 × 2 = 13 units of gas.

Your task is to help the tour operator determine which eastbound street the bus should follow in order to minimize the total cost of the tour while visiting all monuments.

Important Notes

Input

Consists of several lines containing integers separated by single spaces:

The first line contains two integers and y~(1 \le x, y \le 10^5), representing the number of northbound streets and eastbound streets, respectively.

The second line contains an integer n~(1 \le n \le 10^5), the number of monuments to be visited.

The following lines each contain two integers x_i~(0 \le x_i < X) and y_i~(0 \le y_i < Y), denoting the coordinates of a monument.

Output

Print a single integer representing the minimum possible cost of a tour that visits all monuments.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading