#include <iostream>
using namespace std;
void Swap(long *a, long *b)
{
long temp = *a;
*a = *b;
*b = temp;
}
long Partition(long *arr, long start, long end, long *u, long *v)
{
long pivot = arr[end];
long pIndex = start;
long i;
for(i = start; i<end; i++) {
if(arr[i] <= pivot) {
Swap(arr+i, arr+pIndex);
Swap(u+i, u+pIndex);
Swap(v+i, v+pIndex);
pIndex++;
}
}
Swap(arr+pIndex, arr+end);
Swap(u+pIndex, u+end);
Swap(v+pIndex, v+end);
return pIndex;
}
void MSort(long *u, long *v, long *arr, long start, long end)
{
if(start < end) {
long pIndex = Partition(arr, start, end, u, v);
MSort(u, v, arr, start, pIndex-1);
MSort(u, v, arr, pIndex+1, end);
}
}
int main()
{
long n, m, k;
cin >> n >> m >> k;
long i;
long u[m], v[m], l[m];
for(i = 0; i < m; i++) {
cin >> u[i] >> v[i] >> l[i];
}
if(k == 0 || k == n) {
cout << "-1";
}
else {
long arr[k];
long u1[m] = {0}, v1[m] = {0}, l1[m] = {-1};
for(i = 0; i < k; i++)
cin >> arr[i];
long x = 0, j;
for(j = 0; j < k; j++) {
for(i = 0; i < m; i++) {
if(arr[j] == u[i]) {
u1[x] = u[i];
v1[x] = v[i];
l1[x] = l[i];
x++;
} else if(arr[j] == v[i]) {
u1[x] = v[i];
v1[x] = u[i];
l1[x] = l[i];
x++;
}
}
}
MSort(u1, v1, l1, 0, x-1);
long flag = 1;
for(i = 0; i < x; i++) {
flag = 0;
for(j = 0; j < k; j++) {
//cout << v1[i] << " " << arr[j] << " " << endl;
if(v1[i] == arr[j]) {
flag = 1;
break;
}
}
if(flag == 0) {
//cout << i << " ";
cout << l1[i];
break;
}
}
if(flag == 1)
cout << -1;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdm9pZCBTd2FwKGxvbmcgKmEsIGxvbmcgKmIpCnsKICAgIGxvbmcgdGVtcCA9ICphOwogICAgKmEgPSAqYjsKICAgICpiID0gdGVtcDs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gMCB8fCBrID09IG4pIHsKICAgICAgICBjb3V0IDw8ICItMSI7CiAgICB9CiAgICBlbHNlIHsKICAgICAgICBsb25nIGFycltrXTsKICAgICAgICBsb25nIHUxW21dID0gezB9LCB2MVttXSA9IHswfSwgbDFbbV0gPSB7LTF9OwogICAgICAgIGZvcihpID0gMDsgaSA8IGs7IGkrKykKICAgICAgICAgICAgY2luID4+IGFycltpXTsKICAgICAgICBsb25nIHggPSAwLCBqOwogICAgICAgIGZvcihqID0gMDsgaiA8IGs7IGorKykgewogICAgICAgICAgICBmb3IoaSA9IDA7IGkgPCBtOyBpKyspIHsKICAgICAgICAgICAgICAgIGlmKGFycltqXSA9PSB1W2ldKSB7CiAgICAgICAgICAgICAgICAgICAgdTFbeF0gPSB1W2ldOwogICAgICAgICAgICAgICAgICAgIHYxW3hdID0gdltpXTsKICAgICAgICAgICAgICAgICAgICBsMVt4XSA9IGxbaV07CiAgICAgICAgICAgICAgICAgICAgeCsrOwogICAgICAgICAgICAgICAgfSBlbHNlIGlmKGFycltqXSA9PSB2W2ldKSB7CiAgICAgICAgICAgICAgICAgICAgdTFbeF0gPSB2W2ldOwogICAgICAgICAgICAgICAgICAgIHYxW3hdID0gdVtpXTsKICAgICAgICAgICAgICAgICAgICBsMVt4XSA9IGxbaV07CiAgICAgICAgICAgICAgICAgICAgeCsrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIE1Tb3J0KHUxLCB2MSwgbDEsIDAsIHgtMSk7CgogICAgICAgIGxvbmcgZmxhZyA9IDE7CiAgICAgICAgZm9yKGkgPSAwOyBpIDwgeDsgaSsrKSB7CiAgICAgICAgICAgIGZsYWcgPSAwOwogICAgICAgICAgICBmb3IoaiA9IDA7IGogPCBrOyBqKyspIHsKICAgICAgICAgICAgICAgIC8vY291dCA8PCB2MVtpXSA8PCAiICIgPDwgYXJyW2pdIDw8ICIgIiA8PCBlbmRsOwogICAgICAgICAgICAgICAgaWYodjFbaV0gPT0gYXJyW2pdKSB7CiAgICAgICAgICAgICAgICAgICAgZmxhZyA9IDE7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYoZmxhZyA9PSAwKSB7CiAgICAgICAgICAgICAgICAvL2NvdXQgPDwgaSA8PCAiICI7CiAgICAgICAgICAgICAgICBjb3V0IDw8IGwxW2ldOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYoZmxhZyA9PSAxKQogICAgICAgICAgICBjb3V0IDw8IC0xOwogICAgfQogICAgcmV0dXJuIDA7Cn0=