515. Recover path
Time limit per test: 0.75
second(s)
Memory limit: 262144
kilobytes
input: standard
output: standard
Traveller Gregory is famous for his ability to always choose the shortest path for his journey. Ostap is a journalist who seeks for information about the recent Gregory's trip. He managed to get the evidence that during this trip Gregory visited a number of cities. However, there is no information about the order in which they were visited, and no information about the starting city and the ending city of Gregory's trip (the entire trip is (one of) the shortest path between these cities). Help Ostap to find any shortest path that contains all specified cities.
Country in which Gregory traveled consists of
n cities and
m undirected roads between them. For each road Ostap knows the time it takes to travel it, and the "shortest" word above is with respect to those times.
It is guaranteed that there exists some shortest path going through all specified cities.
Input
First line contains two integers
n,
m (1 ≤
n,
m ≤ 10
^{5}). Each of the
m following lines contains a description of a single road
a_{i},
b_{i},
t_{i} (
a_{i} ≠
b_{i}, 1 ≤
a_{i},
b_{i} ≤
n, 1 ≤
t_{i} ≤ 10
^{4}) means Gregory can go between
a_{i} and
b_{i} by road and that will take
t_{i} seconds. The next line contains
k — the number of cities that Ostap knows Gregory has visited. The last line contains a list of these cities. All cities in that list are distinct.
Output
On the first line output the number of roads in the sought shortest path. On the second line output the list of road numbers (numbered in the order of appearing in the input) in the order of that shortest path. If there are many solutions, output any.
Example(s)
sample input

sample output

6 6
1 2 2
2 6 2
1 3 1
3 4 1
4 5 1
5 6 1
3
5 1 3

3
3 4 5

sample input

sample output

6 6
1 2 2
2 6 2
1 3 1
3 4 1
4 5 1
5 6 1
2
1 6

2
1 2
