n, m, r = list(map(int, input().split()))

rs = list(map(int, input().split()))

# construct map

import numpy as np

dists = np.ones((n + 1, n + 1)) * float('inf')

for _ in range(m):

    a, b, c = list(map(int, input().split()))

    dists[a, b] = dists[b, a] = c

for i in range(1, n + 1):

    dists[i, i] = 0



from itertools import product, permutations

for i, k in product(list(range(1, 1 + n)), repeat=2):

    dists[:, k] = np.minimum(dists[:, k], dists[:, i] + dists[i, k])



ans = float('inf')

for path in permutations(rs):

    val = sum(dists[i, j] for i, j in zip(path, path[1:]))

    val = int(val)

    if val < ans:

        ans = val



print(ans)
n, m, r = list(map(int, input().split()))

rs = list(map(int, input().split()))

# construct map

import numpy as np

dists = np.ones((n + 1, n + 1)) * float('inf')

for _ in range(m):

    a, b, c = list(map(int, input().split()))

    dists[a, b] = dists[b, a] = c

for i in range(1, n + 1):

    dists[i, i] = 0



from itertools import product, permutations

for i, j in product(list(range(1, 1 + n)), repeat=2):

    dists[j] = np.minimum(dists[j], dists[i] + dists[j, i])



ans = float('inf')

for path in permutations(rs):

    val = sum(dists[i, j] for i, j in zip(path, path[1:]))

    val = int(val)

    if val < ans:

        ans = val



print(ans)
n, m, r = list(map(int, input().split()))
rs = list(map(int, input().split()))
# construct map
import numpy as np

dists = np.ones((n + 1, n + 1)) * float("inf")
for _ in range(m):
    a, b, c = list(map(int, input().split()))
    dists[a, b] = dists[b, a] = c
for i in range(1, n + 1):
    dists[i, i] = 0
from itertools import product, permutations

for i, k in product(list(range(1, 1 + n)), repeat=2):
    dists[:, k] = np.minimum(dists[:, k], dists[:, i] + dists[i, k])
ans = float("inf")
for path in permutations(rs):
    val = sum(dists[i, j] for i, j in zip(path, path[1:]))
    val = int(val)
    if val < ans:
        ans = val
print(ans)

n, m, r = list(map(int, input().split()))
rs = list(map(int, input().split()))
# construct map
import numpy as np

dists = np.ones((n + 1, n + 1)) * float("inf")
for _ in range(m):
    a, b, c = list(map(int, input().split()))
    dists[a, b] = dists[b, a] = c
for i in range(1, n + 1):
    dists[i, i] = 0
from itertools import product, permutations

for i, j in product(list(range(1, 1 + n)), repeat=2):
    dists[j] = np.minimum(dists[j], dists[i] + dists[j, i])
ans = float("inf")
for path in permutations(rs):
    val = sum(dists[i, j] for i, j in zip(path, path[1:]))
    val = int(val)
    if val < ans:
        ans = val
print(ans)

-for i, k in product(list(range(1, 1 + n)), repeat=2): -    dists[:, k] = np.minimum(dists[:, k], dists[:, i] + dists[i, k]) +for i, j in product(list(range(1, 1 + n)), repeat=2): +    dists[j] = np.minimum(dists[j], dists[i] + dists[j, i])