The great Emperor, Lord Pooty, decided to retire and would like to hand over the crown to one of his many sons. In the spirit of democracy, he decided to do this with a vote! His kingdom consists of N cities labelled from 0 to N−1. Of these N cities, K of them are voting cities where voting can be done. The ith voting city is T_i.
As a reponsible member of society, you decided that it is only right for you to do your civic duty. You are to travel to one of the designated voting cities to vote! There are E roads that can be used. Road j connects city U_j to city V_j in one direction and has a toll of C_j. Luckily, due to this event, local cities have opened a ticket system to reduce the cost of traveling.
There are 5 different types of tickets to choose from, numbered from type 1 to type 5. A ticket of type x will reduce the cost of the toll on a road by (10x). In other words, the cost of the road will be multiplied by (1−10x) if a ticket of type x is used.
However, there are a few rules regarding the tickets. You cannot use more than one ticket on one road to stack the effects. You are only allowed to buy at most one of each ticket at the start of your journey. For example, you can choose to buy one type 1 ticket and one type 2 ticket but are not allowed to buy two type 2 tickets. This is to prevent people from hoarding the tickets. You are only allowed to buy the tickets at the start of your journey.
You are a busy man and unfortunately, you do not know which city you may start your journey from, nor do you know the ticket prices. You have made a list of Q possible situations, comprised of a starting city S and ticket prices P_1, P_2, P_3, P_4 and P_5 for the 5 tickets. It is possible that a certain ticket may not even be available, and in that case the ticket price will be −1.
For each of these situations, find the minimum cost to one of the voting city if it is reachable by road. Do note that not every city is reachable from every other and you may have to walk..
Your program must read from standard input.
The first line of input contains 3 integers N, E and K representing the number of cities, number of roads and number of voting cities respectively. The second line contains K integers, the ith one representing T_i, the ith voting city.
The next E contain 3 integers each. The jth of these lines consists of U_j, V_j and C_j respectively, representing a unidirectional road from U_j to V_j with cost C_j. It is guaranteed that C_j is divisible by 10.
The next line contains a single integer Q, representing the number of situations to be considered.
The next Q lines contain 6 integers S, P_1, P_2, P_3, P_4 and P_5 representing the starting city and the prices of the tickets of type 1 to type 5 respectively. Note that the starting city and ticket prices can differ across the different situations provided.
Your program must print to standard output.
Output Q lines with 1 integer on each line, representing the lowest cost to a voting city for each situation in the order provided in the input. If a path does not exist for a situation, print −1 instead.