Global firefighters

A new criminal group named Arsenists Without Borders are lighthing fires
all over the world with a special chemical composition that makes the
fires hard to neutralize. So, in order to protect people, during the
last UN reunion it was decided to create a global unit of firefighters.
But now they need some nice slogans about how good are the firefighters.
Explicitely, they want to advertise how much time it will take them to
get to some locations.

Input

Input starts with the number of cases. Every case begins with the number
of cities n and the number of roads m. Follow m triples (u, v, d) to
indicate a bidirectional road from u to v (with u ≠ v) of length d > 0.
Afterwards, we have a number k, followed by k different cities where the
firefighter units are located. Finally, we have the number of queries q
for this case, followed by q numbers of a city (numbered from 0 to
n − 1). You can suppose that the map is connected, and that there is at
most one single road directly connecting two cities. Assume 0 < n ≤ 10⁵,
n − 1 ≤ m ≤ 30n, 0 < k ≤ min (n, 1000), and 0 < q ≤ 1000.

Output

For every case, print first its number starting at one. Afterwards, for
each query, provide the distance between the city and the closest
firefighter unit, and in which city it is located (in case of a tie,
print the lowest number). Separate the output for two cases with a blank
line.

Problem information

Author: Francesc Martínez

Generation: 2026-01-25T11:20:06.452Z

© Jutge.org, 2006–2026.
https://jutge.org
