30 Minutes or Less

Gridland is a grid-shaped city whose streets are numbered consecutively starting at 1, from left to right and from south to north. The distance between two city locations (x1,y1) and (x2,y2) is the usual Manhattan distance, i.e., |x2 − x1| + |y2 − y1|. Pizza Planet, the largest fast food chain in Gridland and the franchise with most restaurants across the city, plans to implement the 30 minutes or less guarantee in its delivery service: either customers receive their pizzas within 30 minutes after placing the order or otherwise the pizza order is on the house. Your task is to reduce the pizza delivery times, i.e., to minimize the total distance delivery guys from Pizza Planet restaurants must travel to make all deliveries. Each pizza order must be delivered and each restaurant can dispatch at most one pizza order. Input There are several test cases. Each case begins with a blank-separated pair of integer numbers R and N: the number of restaurants (1 ≤ R ≤ 100) and the number of pizza orders (1 ≤ N ≤ R). Then R + N lines of blank-separated pairs of integers x and y follow (−103 ≤ x ≤ 103, −103 ≤ y ≤ 103): each of the first R lines indicates the location of a Pizza Planet restaurant and each of the last N lines indicates the location where a pizza order must be delivered. Output For each case, print the minimum distance the delivery guys must travel to make all deliveries. Sample Input 22 15 21 42 43 32 21 43 74 45 5 -1 Sample Output 8 7