#include <iostream>
#include <queue>
#include <cstring>
#define x first
#define y second
using namespace std;
const int N = 1e5+10, M = 3*N; //M:还有虚拟源点
typedef pair<int, int> PII;
int h[N], e[M], ne[M], w[M], idx; //w:两个点之间的距离
int dist[N];
int n, m, q, k;
bool vi[N]; //是否已经确立了最短路径
void add(int a, int b, int c)
{
e[idx] = b, ne[idx] = h[a], w[idx] = c, h[a] = idx++;
}
void djkstra()
{
priority_queue<PII, vector<PII>, greater<PII>> heap;
heap.push({0, 0}); //距离,编号。先把虚拟源点加到堆中
memset(dist, 0x3f, sizeof dist);
dist[0] = 0;
while (heap.size())
{
auto t = heap.top();
heap.pop();
int ver = t.y, d = t.x; //当前的最短距离,编号
if (vi[ver]) continue;
vi[ver] = true;
//遍历邻接点
for (int i = h[ver]; ~i; i = ne[i])
{
int j = e[i]; //编号
if (dist[j] > d + w[i])
{
dist[j] = d + w[i];
heap.push({dist[j], j});
}
}
}
}
int main()
{
memset(h, -1, sizeof h);
scanf("%d%d", &n, &m);
while (m--)
{
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
add(a, b, c), add(b, a, c);
}
scanf("%d", &k);
while (k--)
{
int x;
scanf("%d", &x);
add(0, x, 0); //设虚拟源点是0,到所有起点的距离都是0,单向
}
djkstra();
scanf("%d", &q);
while (q--)
{
int x;
scanf("%d", &x);
printf("%d\n", dist[x]);
}
return 0;
}