Optimum Server Location

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

The world's best IT company Oondex is coming to Lineland! After years of facing annoying "This service is not available in your area" error messages, Linelanders will finally be able to listen to the most popular music, watch fresh viral videos and use lots of other opportunities provided by Oondex's services. 

Lineland can be seen as a real coordinate line. It has unusual network tariffs: connecting two servers dd kilometers apart from each other with a network channel of throughput tt Mbit/s costs dtd \cdot t dollars. 

In order to provide better user experience, Oondex is going to place nn servers in Lineland. These servers will be performing regular data processing activities which requires intense pairwise network interaction between these servers. At the same time, these servers are going to serve external users using mm special CDN servers (which are specialized content delivery servers) already present in Lineland. 

Analysts of Oondex determined for each pair ii, jj (1i<jn1 \leq i < j \leq n) the required throughput d_ijd\_{ij} Mbit/sec between servers ii and jj, and also for each pair ii, kk (1in1 \leq i \leq n; 1km1 \leq k \leq m) the required throughput c_ikc\_{ik} Mbit/sec between server ii and CDN server kk

Given the locations of CDN servers a_ka\_k (1km1 \leq k \leq m), determine the locations x_ix\_i (1in1 \leq i \leq n) such that the cost of placing servers into them is the minimum possible. Formally, determine x_ix\_i such that the cost value of v=_1i<jnx_ix_jd_ij+_1in 1kmx_ia_kc_ikv = \sum\limits\_{1 \leq i < j \leq n} |x\_i - x\_j| \cdot d\_{ij} + \sum\limits\_{\substack{1 \leq i \leq n \\\ 1 \leq k \leq m}} |x\_i - a\_k| \cdot c\_{ik} is the minimum possible. Multiple servers (both Oondex and CDN) may be located at the same point.

입력

The first line contains two integers nn and mm (1n,m701 \leq n, m \leq 70) --- the number of Oondex servers to place and the number of existing CDN servers.

The second line contains mm integers a_1,a_2,,a_ma\_1, a\_2, \ldots, a\_m (0a_k1060 \leq a\_k \leq 10^6) --- the locations of existing CDN servers.

The ii-th of the next nn lines contains mm integers c_i1,c_i2,,c_imc\_{i1}, c\_{i2}, \ldots, c\_{im} where c_ikc\_{ik} (0c_ik500 \leq c\_{ik} \leq 50) is the throughput between ii-th Oondex server and the kk-th CDN server.

Finally, the ii-th of the next nn lines contains nn integers d_i1,d_i2,,d_ind\_{i1}, d\_{i2}, \ldots, d\_{in} (0d_ij500 \leq d\_{ij} \leq 50; d_ij=d_jid\_{ij} = d\_{ji}; d_ii=0d\_{ii} = 0) where d_ijd\_{ij} is the throughput between jj-th Oondex server and the ii-th Oondex server.

출력

On the first line output the value vv --- the minimum possible cost of placing nn Oondex servers.

On the second line output nn integers x_1,x_2,,x_nx\_1, x\_2, \ldots, x\_n where x_ix\_i (0x_i1060 \leq x\_i \leq 10^6) --- the coordinates at which the ii-th Oondex server should be placed. It can be proven that an optimum answer satisfying these restrictions on x_ix\_i (range and integrality) exists.