#P5096. Cow Cave Adventure

    ID: 18334 Type: Default 1000ms 256MiB

Cow Cave Adventure

Cow Cave Adventure

Few people know that cows love to explore caves. In a cave there are NN (1N1001 \leq N \leq 100) chambers connected by MM (1M10001 \leq M \leq 1000) bidirectional corridors. Each pair of chambers is connected by at most one corridor. Additionally, there are KK (1K141 \leq K \leq 14) chambers that contain a bundle of hay. When Betsy the cow eats one bundle of hay, her weight index increases by 11.

Betsy starts her adventure at chamber 11 with a weight index of 00. However, every corridor has a width threshold. If her current weight index exceeds the threshold of a corridor (i.e. if her weight index is greater than the threshold), she will get stuck. After exploring the cave, she must return to chamber 11.

Determine the maximum number of hay bundles Betsy can eat. Note that when passing through a chamber with hay, she does not have to eat the hay immediately.

inputFormat

The first line contains three integers NN, MM, and KK.

The next MM lines each contain three integers uu, vv, and ww, indicating that there is a bidirectional corridor between chambers uu and vv with a width threshold ww. (A corridor can be traversed if and only if the current weight index is less than or equal to its threshold.)

The following KK lines each contain one integer representing a chamber that contains a bundle of hay. It is guaranteed that these chambers are distinct.

outputFormat

Output a single integer representing the maximum number of hay bundles Betsy can eat while starting and ending at chamber 11.

sample

4 4 2
1 2 3
2 3 1
3 4 1
4 1 1
2
3
1