Voting Cities

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

문제

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 NN cities labelled from 00 to N1N - 1. Of these NN cities, KK of them are voting cities where voting can be done. The iith voting city is T_iT\_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 EE roads that can be used. Road jj connects city U_jU\_j to city V_jV\_j in one direction and has a toll of C_jC\_j. Luckily, due to this event, local cities have opened a ticket system to reduce the cost of traveling.

There are 55 different types of tickets to choose from, numbered from type 11 to type 55. A ticket of type xx will reduce the cost of the toll on a road by (10x)(10x)\\%. In other words, the cost of the road will be multiplied by (1x10)\left(1 - \frac{x}{10}\right) if a ticket of type xx 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 11 ticket and one type 22 ticket but are not allowed to buy two type 22 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 QQ possible situations, comprised of a starting city SS and ticket prices P_1P\_1, P_2P\_2, P_3P\_3, P_4P\_4 and P_5P\_5 for the 55 tickets. It is possible that a certain ticket may not even be available, and in that case the ticket price will be 1-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 33 integers NN, EE and KK representing the number of cities, number of roads and number of voting cities respectively. The second line contains KK integers, the iith one representing T_iT\_i, the iith voting city.

The next EE contain 33 integers each. The jjth of these lines consists of U_jU\_j, V_jV\_j and C_jC\_j respectively, representing a unidirectional road from U_jU\_j to V_jV\_j with cost C_jC\_j. It is guaranteed that C_jC\_j is divisible by 1010.

The next line contains a single integer QQ, representing the number of situations to be considered.

The next QQ lines contain 66 integers SS, P_1P\_1, P_2P\_2, P_3P\_3, P_4P\_4 and P_5P\_5 representing the starting city and the prices of the tickets of type 11 to type 55 respectively. Note that the starting city and ticket prices can differ across the different situations provided.

출력

Your program must print to standard output.

Output QQ lines with 11 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-1 instead.

제한

  • 1N50001 ≤ N ≤ 5000
  • 0E10000 0 ≤ E ≤ 10000
  • 1Q1001 ≤ Q ≤ 100
  • 0KN0 ≤ K ≤ N
  • 0T_i<N0 ≤ T\_i < N for all 1iK1 ≤ i ≤ K
  • T_iT_jT\_i \ne T\_j for all 1i<jK1 ≤ i < j ≤ K
  • 1C_i1091 ≤ C\_i ≤ 10^9 for all 1iE1 ≤ i ≤ E
  • C_iC\_i is a multiple of 1010 for all 1iE1 ≤ i ≤ E
  • 0U_i,V_i<N0 ≤ U\_i , V\_i < N and U_iV_iU\_i \ne V\_i for all 1iE1 ≤ i ≤ E
  • 1P_i109-1 ≤ P\_i ≤ 10^9 for all 1i51 ≤ i ≤ 5