Under construction

Still being built. Things may change

In the cube

Time limit3sMemory limit1024 MB

Summary
Place k tables on the 5001 by 5001 grid, away from the n stands, so the total of each table's distances to its c closest stands is minimal.
Level

Hard8 of 10

Topics
Dynamic programming, Bit manipulation, Sorting
Solved
No attempts yet

Problem

Taja likes to go to the cafe In the cube with her friends, since it has a very convenient ordering system. To place an order, a guest walks to an automated stand and chooses any dishes they like. There are several stands, and each is fixed at a specific place inside the cafe.

Guests sit in front of tables. There are kk tables. The iith table can serve at most cic_i persons. The uncomfortableness of a table is the sum of distances from that table to the cic_i stands closest to it.

Formally, the cafe is the grid (0,0)(0, 0) to (5000,5000)(5000, 5000). Each cell (x,y)(x, y) (0≤x,y≤50000 \le x, y \le 5000) can contain either one automated stand, one table, or nothing. The distance between cells (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) is ∣x2−x1∣+∣y2−y1∣|x_2 - x_1| + |y_2 - y_1|.

Arrange the tables so that the total uncomfortableness of all tables is minimal.

Input

The first line contains two integers nn and kk (1≤n≤181 \le n \le 18, 1≤k≤2001 \le k \le 200), the number of automated stands and the number of tables.

Each of the next nn lines contains the coordinates xix_i and yiy_i of the iith stand (0≤xi,yi≤50000 \le x_i, y_i \le 5000).

Each of the next kk lines contains a single integer cjc_j (1≤cj≤n1 \le c_j \le n), the number of seats at the jjth table.

Output

Output one integer, the minimal total uncomfortableness.

Hint

A possible arrangement of the tables for the first sample is shown above.

Examples2

  1. Example 1

    Input
    3 4
    1 2
    4 1
    5 4
    1
    2
    3
    3
    
    Expected output
    20
    
  2. Example 2

    Input
    2 10
    0 0
    5000 5000
    1
    1
    1
    1
    1
    1
    1
    1
    1
    1
    
    Expected output
    16