#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 15;
vector<pair<int,int> > g[N];
int dp[(1<<N)+5], MSK;
int n, m, k;
int calc(int msk) {
if((msk&MSK) == MSK) return 0;
int &ret = dp[msk];
if(ret != -1) return ret;
ret = 1e9;
if(msk == 0) {
for(int u=0; u<n; ++u)
ret = min(ret, calc(1<<u));
} else {
for(int u=0; u<n; ++u)
if((msk>>u)&1) {
for(int i=0, v, c; i<g[u].size(); ++i) {
v = g[u][i].first;
c = g[u][i].second;
if(!((msk>>v)&1))
ret = min(ret, c + calc(msk | (1<<v)));
}
}
}
return ret;
}
int main() {
int t;
scanf("%d", &t);
while(t--) {
scanf("%d%d%d", &n, &m, &k);
for(int i=0; i<n; ++i)
g[i].clear();
for(int i=0, u, v, c; i<m; ++i) {
scanf("%d%d%d", &u, &v, &c);
--u, --v;
g[u].push_back(make_pair(v, c));
g[v].push_back(make_pair(u, c));
}
MSK = 0;
for(int i=0, x; i<k; ++i) {
scanf("%d", &x);
--x;
MSK |= (1<<x);
}
memset(dp, -1, sizeof dp);
printf("%d\n", calc(0));
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnR5cGVkZWYgbG9uZyBsb25nIGxsOwp1c2luZyBuYW1lc3BhY2Ugc3RkOwpjb25zdCBpbnQgTiA9IDE1Owp2ZWN0b3I8cGFpcjxpbnQsaW50PiA+IGdbTl07CmludCBkcFsoMTw8TikrNV0sIE1TSzsKCmludCBuLCBtLCBrOwppbnQgY2FsYyhpbnQgbXNrKSB7CglpZigobXNrJk1TSykgPT0gTVNLKSByZXR1cm4gMDsKCWludCAmcmV0ID0gZHBbbXNrXTsKCWlmKHJldCAhPSAtMSkgcmV0dXJuIHJldDsKCXJldCA9IDFlOTsKCWlmKG1zayA9PSAwKSB7CgkJZm9yKGludCB1PTA7IHU8bjsgKyt1KQoJCQlyZXQgPSBtaW4ocmV0LCBjYWxjKDE8PHUpKTsKCX0gZWxzZSB7CgkJZm9yKGludC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