Under construction

Still being built. Things may change

Late Party

Time limit1sMemory limit512 MB

Summary
On an undirected weighted graph, find the longest prefix of your walk home during which at least one friend still shares some shortest path with you.
Level

Hard8 of 10

Topics
Graph, Shortest path, Greedy, Sorting
Solved
No attempts yet

Problem

After tonight's banquet, you will leave the banquet hall together with the F new friends you have made and walk back to your hotel. You want to keep chatting with them as long as possible, though you may not all be staying at the same hotel.

Everyone, you included, takes one of the shortest paths back to their hotel.

Paris consists of N intersections numbered from 0 to N − 1 and S streets linking two intersections. Streets can of course be walked in both directions. All hotels are located at intersections and are reachable from the banquet. The banquet takes place at intersection number 0.

Input

The input consists of several lines, each containing integers separated by single spaces:

  • The first line contains the three integers N, S, and F.
  • Each of the following S lines contains three integers i, j, t, representing a street between intersections i and j that takes t minutes to walk through.
  • The last line contains F + 1 integers representing the intersections of the hotels where people stay; the first is yours, the others are your friends' respective hotels.

Output

The output consists of a single line containing one integer: the longest time (in minutes) you can stay accompanied by at least one friend.

Constraints

  • 1 ≤ N ≤ 100 000
  • 0 ≤ S ≤ 300 000
  • 0 ≤ F ≤ 10 000
  • 1 ≤ t ≤ 1 000 000

Examples1

  1. Example 1

    Input
    7 12 1
    0 1 1
    0 2 2
    0 2 4
    1 3 2
    2 3 1
    1 4 2
    4 2 2
    1 5 3
    2 5 1
    5 6 2
    4 6 2
    3 6 3
    3 6
    
    Expected output
    2