#include <iostream>
#include <queue>
#include <cstring>
#define x first
#define y second
using namespace std;
typedef pair<int, int> PII;
const int N = 100010, M = 200010;
int n, m;
int h[N], e[M], ne[M], w[M], idx;
int dist[N];
bool st[N];
priority_queue<PII, vector<PII>, greater<PII>> heap;
void add(int a, int b, int c)
{
e[idx] = b, ne[idx] = h[a], w[idx] = c, h[a] = idx++;
}
void dijkstra()
{
while (heap.size())
{
auto t = heap.top();
heap.pop();
int v = t.y;
if (st[v]) continue;
st[v] = true;
for (int i = h[v]; ~i; i = ne[i])
{
int j = e[i];
if (dist[j] > dist[v] + w[i])
dist[j] = dist[v] + w[i], heap.push({dist[j], j});
}
}
}
int main()
{
cin >> n >> m;
memset(h, -1, sizeof h);
while (m--)
{
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
add(a, b, c), add(b, a, c);
}
memset(dist, 0x3f, sizeof dist);
int k;
cin >> k;
while (k--)
{
int x;
scanf("%d", &x);
dist[x] = 0;
heap.push({0, x});
}
dijkstra();
int q;
cin >> q;
while (q--)
{
int x;
scanf("%d", &x);
printf("%d\n", dist[x]);
}
return 0;
}