Fly or not fly
Welcome to Mars! Your first mission is to send letters to K cities A_1, A_2, …, A_K in order. Mars consists of N cities connected by roads, different roads may have different lengths, in city i there are P_i UFOs which you can take to increase your speed, let’s assume that the road’s length is x, so if you walk through this road, you’ll spend 5x minutes, but if you fly (by UFO of course), you’ll only spend x minutes. However, you must have this mission done in minimal time, and each UFO can only be used once, it disappears when you leave it, you can’t send letters when you are in the UFO, so you must leave it in order to send a letter.
Input
There are several test cases, end with EOF. For each test case, the first line contains two integers N ≤ 100, andK ≤ N, the second line is N integers, P_1, P_2, …, P_N.(P_i ≤ 10), Next N lines is an N×N matrix G_{1..N,1..N} for the lengths between every two cities(G_{i,j} ≤ 100), it is guaranteed that G_{i,j}=G_{j,i} and G_{i,i}=0, if G_{i,j}=-1, it means that there is no road between city i and j. The last line of each case is K integers A_1, A_2, …, A_K. You are in city A_1 at first.
Output
For each the case, output the minimal time.