http://acm.hdu.edu.cn/showproblem.php?pid=6705
#include <iostream>
#include <cstring>
#include <queue>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <map>
#include <cmath>
//#include<bits/stdc++.h>
using namespace std;
#define sfi(i) scanf("%d",&i)
#define sfl(i) scanf("%I64d",&i)
#define sfs(i) scanf("%s",(i))
#define pri(i) printf("%d\n",i)
#define prl(i) printf("%I64d\n",i)
#define sff(i) scanf("%lf",&i)
#define ll long long
#define ull unsigned long long
#define mem(x,y) memset(x,y,sizeof(x))
#define INF 0x3f3f3f3f
#define eps 1e-10
#define PI acos(-1.0)
#define lowbit(x) ((x)&(-x))
#define fl() printf("flag\n")
#define MOD(x) ((x%mod)+mod)%mod
#define endl '\n'
#define pb push_back
#define lson (rt<<1)
#define rson (rt<<1|1)
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
const int maxn=5e5+9;
int n,m,q;
int Max=0;
struct Q
{
int pos;
}que[maxn];
vector<pair<ll,int> > g[maxn];
struct node
{
int st,ed,index;
ll w;
node(){}
node(int _st,int _ed,ll _cost,int _index)
{
st=_st;
ed=_ed;
index=_index;
w=_cost;
}
bool operator < (const node &b) const
{
return w>b.w;
}
};
priority_queue<node>qq;
ll ans[maxn];
void dj()
{
for(int i=1;i<=n;i++)
{
sort(g[i].begin(),g[i].end());
}
for(int i=1;i<=n;i++)
{
if(g[i].size())
qq.push(node(i,i,g[i][0].first,0));
//cout<<i<<" "<<g[i][0].first<<endl;
}
int kk=0;
while(!qq.empty())
{
node tmp=qq.top();
qq.pop();
int st=tmp.st;
int ed=tmp.ed;
int index=tmp.index;
ll w=tmp.w;
int nex=g[ed][index].second;
//cout<<st<<" "<<ed<<" "<<index<<" "<<nex<<" "<<w<<" "<<w+g[nex][0].first<<endl;
ans[++kk]=w;
//cout<<kk<<endl;
if(kk==Max) break;
if(g[nex].size())
qq.push(node(st,nex,w+g[nex][0].first,0));
if(index+1<g[ed].size())
{
qq.push(node(st,ed,w-g[ed][index].first+g[ed][index+1].first,index+1));
//cout<<g[ed][index+1].first<<endl;
}
}
}
int main()
{
FAST_IO;
//freopen("input.txt","r",stdin);
int T;
cin>>T;
while(T--)
{
while(!qq.empty()) qq.pop();
Max=0;
cin>>n>>m>>q;
int u,v;
for(int i=0;i<=n;i++) g[i].clear();
ll w;
for(int i=0;i<m;i++)
{
cin>>u>>v>>w;
g[u].pb({w,v});
}
for(int i=0;i<q;i++)
{
int pos;
cin>>pos;
que[i].pos=pos;
Max=max(Max,pos);
}
dj();
//fl();
for(int i=0;i<q;i++)
{
cout<<ans[que[i].pos]<<endl;
}
}
return 0;
}