PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#FW0000099. Mua hàng trong thành phố (Shopping)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Mua hàng trong thành phố (Shopping)

Shopping

Source: Kattis

Version: Phuoc Hung OJ Extended

Problem Statement

Home is intersection 00. A set of distinct stores must be visited. Roads are bidirectional and positively weighted (parallel roads may exist). Find a shortest driving route starting and ending at home and visiting every store.

Input

First n,mn,m, then mm roads u,v,wu,v,w (zero-based vertices). Next ss, then ss store vertices, one per line allowed.

Output

Print the minimum total distance.

Subtasks

  • Subtask 1 (40 points): 3≤n≤9,  1≤s≤43\le n\le 9,\;1\le s\le 4. All input-format and graph conditions above apply.

  • Subtask 2 (60 points): 3≤n≤28,  1≤s≤83\le n\le 28,\;1\le s\le 8. All input-format and graph conditions above apply.

Examples

Input

2 1
0 1 4
1
1

Output

8

Explanation

The sole required store is at vertex 1. The shortest tour is 0→1→00\to1\to0, totaling 4+4=84+4=8.