시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
7 초 512 MB 1 1 1 100.000%

문제

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 (x1, y1) to a point (x2, y2) is |x1 − x2| + |y1 − y2|.

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.

입력

The input comprises several lines, each consisting of integers separated with single spaces:

  • The first line consists of the number N of wine bottles to collect and the number M of available couriers.
  • The N following lines consist of the coordinates of each bottle as two integers x and y.
  • The M following lines consist of the coordinates of each courier’s base as two integers x and y.
  • The last line contains the coordinates of the restaurant as two integers x and y.

Limits

  • 1 ≤ N ≤ 1 000;
  • 1 ≤ M ≤ 1 000;
  • all coordinates (x, y) verify −1 000 ≤ x ≤ 1 000 and −1 000 ≤ y ≤ 1 000.

출력

A single integer: the smallest number of euros that needs to be paid to collect all bottles.

예제 입력 1

2 2
1 0
0 -1
-1 1
2 -1
0 0

예제 출력 1

5

힌트

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.

On this example, only one courier (C2) is used to retrieve the two bottles B1 and B2, and bring them to the restaurant R by performing the moves labeled 1 to 4 in succession. The total number of kilometers is 5. This is one of the optimal solutions.