A Parisian entrepreneur has just opened a new restaurant "Au bon cordon bleu", named after a famous French recipe. However, no one has any idea of which wine would be appropriate with such a dish. The entrepreneur plans to sample many different wines in order to build the wine menu.
The various bottles of wine he plans to taste can be obtained from different wine merchants located in or around Paris. Being a very sensitive product, high-quality wine can only be transported by highly trained couriers on motorbikes. Therefore, those couriers are very expensive.
A courier can be used for the transportation of several wine bottles, but can transport only one bottle at a time. All couriers get paid at the same fixed rate: one euro per kilometer. The distance function used is the Manhattan distance (also known as taxicab metric) of every individual segment of the trip: the distance from a point to a point is .
A courier in charge of transporting a single wine bottle will get paid as many euros as the sum of the following two (Manhattan) distances: from her base to the wine merchant place, and from the wine merchant place to the restaurant.
Consider a more complex example: a courier in charge of transporting two wine bottles, one after the other. The amount paid will be the sum of the following distances: from his base to the location of the first bottle, then to the restaurant, then to the location of the second bottle, then to the restaurant.
Help the entrepreneur minimize the costs of hiring the couriers. Given a set of Cartesian coordinates corresponding to available couriers, a set of Cartesian coordinates corresponding to the locations of the precious wine bottles they need to collect, and the location of the restaurant, compute the smallest number of kilometers that the couriers will be paid for. There is no obligation to use all available couriers, and bottles can be collected in an arbitrary order.
Input Specification
The input comprises several lines, each consisting of integers separated with single spaces:
- The first line consists of the number of wine bottles to collect and the number of available couriers.
- The following lines consist of the coordinates of each bottle as two integers and .
- The following lines consist of the coordinates of each courier's base as two integers and .
- The last line contains the coordinates of the restaurant as two integers and .
Constraints
- ;
- ;
- all coordinates satisfy .
Output Specification
A single integer: the smallest number of euros that needs to be paid to collect all bottles.
Notes
There might be more than one item at the same initial location. For example, it would be possible for two bottles, ten couriers, and the restaurant to share the same starting position.
Example
On this example, only one courier () is used to retrieve the two bottles and , and bring them to the restaurant by performing the moves labeled 1 to 4 in succession. The total number of kilometers is 5. This is one of the optimal solutions.
Sample Input
2 2
1 0
0 -1
-1 1
2 -1
0 0
Sample Output
5
Comments
can the couriers also go back to their base, or from one merchant to another?