#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=200000+10;
int T,n,m,q,cnt,tot;
bool red[N];
int last[N],pos[N],f[N],rmq[N],mm[N],dp[N][20],a[N];
ll cost[N],cost_t[N];
struct tree{
int v,w,nex;
}t[N];
bool cmp(int a,int b)
{
return cost_t[a]>cost_t[b];
}
void add(int x,int y,int z)
{
cnt++;
t[cnt].v=y;
t[cnt].nex=last[x];
last[x]=cnt;
t[cnt].w=z;
}
void dfs(int x,int fa,int deep,ll dis,ll dis1)
{
if (red[x]) dis1=0;
cost[x]=dis; cost_t[x]=dis1;
pos[x]=tot; f[tot]=x; rmq[tot++]=deep;
for (int i=last[x];i;i=t[i].nex)
{
if (t[i].v==fa) continue;
dfs(t[i].v,x,deep+1,dis+t[i].w,dis1+t[i].w);
f[tot]=x;
rmq[tot++]=deep;
}
}
void ST(int n)
{
mm[0]=-1;
for (int i=1;i<=n;i++)
{
mm[i]=((i&(i-1))==0) ? mm[i-1]+1:mm[i-1];
dp[i][0]=i;
}
for (int j=1;j<=mm[n];j++)
for (int i=1;i+(1<<j)-1<=n;i++)
dp[i][j]=rmq[dp[i][j-1]]<rmq[dp[i+(1<<(j-1))][j-1]] ? dp[i][j-1] : dp[i+(1<<(j-1))][j-1];
}
int query(int a,int b)
{
a=pos[a]; b=pos[b];
if (a>b) swap(a,b);
int k=mm[b-a+1];
int ret=rmq[dp[a][k]]<=rmq[dp[b-(1<<k)+1][k]] ? dp[a][k] : dp[b-(1<<k)+1][k];
return f[ret];
}
int main()
{
scanf("%d",&T);
while (T--)
{
int x,y,z,k;
cnt=0; tot=1;
memset(red,0,sizeof(red));
memset(last,0, sizeof(last));
scanf("%d%d%d",&n,&m,&q);
for (int i=1;i<=m;i++)
{
scanf("%d",&x);
red[x]=true;
}
for (int i=1;i<n;i++)
{
scanf("%d%d%d",&x,&y,&z);
add(x,y,z); add(y,x,z);
}
cost[1]=cost_t[1]=cost_t[n+1]=0;
dfs(1,-1,1,0,0);
ST(tot-1);
while (q--)
{
scanf("%d",&k);
for (int i=1;i<=k;i++) scanf("%d",&a[i]);
sort(a+1,a+1+k,cmp); a[k+1]=n+1;
ll ans=cost_t[a[2]],lon,maxx=0;
int fa=a[1];
for (int i=2;i<=k;i++)
{
int new_fa=query(fa,a[i]);
int dep1=rmq[pos[fa]],dep2=rmq[pos[new_fa]];
if (dep2<dep1) maxx+=cost[fa]-cost[new_fa];
lon=min(cost_t[a[i]],cost[a[i]]-cost[new_fa]);
maxx=max(maxx,lon);
fa=new_fa;
ans=min(ans,max(maxx,cost_t[a[i+1]]));
}
printf("%lld\n",ans);
}
}
return 0;
}