#include<bits/stdc++.h>
#include<fstream>
using namespace std;
#define sz(a) (int)a.size()
#define TIME (1.0 * clock() / CLOCKS_PER_SEC)
#define ll long long
#define int long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const ld PI = 3.14159265359;
const ll mod = 998244353;
const int mxn = 3e5 + 5, mxm = 1e5;
int n, m, d;
ll dis[mxn + 1], a[mxn + 1], x[mxn + 1];
int up[mxn + 1][20], in[mxn + 1];
vt<pii>adj[mxn + 1];
vt<int>g[mxn + 1];
pii dp[mxn + 1];
void ckmin(pii &a, pii b){
if(b.fi < a.fi)a = b;
else if(a.fi == b.fi){
if(b.se > a.se)a = b;
}
}
int get(int l, int r){
int lg = __lg(r - l + 1);
return(max(up[l][lg], up[r - (1 << lg) + 1][lg]));
}
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> m;
forr(i, 0, m){
int u, v, w; cin >> u >> v >> w;
adj[u].pb({v, w}); adj[v].pb({u, w});
}
for(int i = 1; i <= n; i++)dis[i] = 1e18;
priority_queue<pll, vt<pll>, greater<pll>>pq;
int k; cin >> k;
forr(i, 0, k){
cin >> a[i]; dis[a[i]] = 0; pq.push({dis[a[i]], a[i]});
}
cin >> d;
for(int i = 1; i <= d; i++){
cin >> x[i]; up[i][0] = x[i];
}
for(int i = 1; i < 20; i++){
for(int j = 1; j + (1 << i) - 1 <= d; j++){
up[j][i] = max(up[j][i - 1], up[j + (1 << (i - 1))][i - 1]);
}
}
while(!pq.empty()){
auto [dd, u] = pq.top(); pq.pop();
if(dis[u] != dd)continue;
for(auto [v, w]: adj[u]){
if(dis[v] > dis[u] + w){
dis[v] = dis[u] + w;
pq.push({dis[v], v});
}
}
}
for(int i = 1; i <= n; i++){
//cout << dis[i] << " ";
for(auto [v, w]: adj[i]){
if(dis[i] + w == dis[v]){
g[i].pb(v); in[v]++;
}
}
}
for(int i = 1; i <= n; i++){
dp[i] = make_pair(1e9, 0);
}
queue<int>q;
for(int i = 1; i <= n; i++){
if(in[i] == 0 && dis[i] < 1e18){
dp[i] = make_pair(0, 0);
q.push(i);
}
}
while(!q.empty()){
int nw = q.front(); q.pop();
for(auto i: g[nw]){
ll need = dis[i] - dis[nw];
if(dp[nw].se >= need && dp[nw].fi != 1e9){
ckmin(dp[i], make_pair(dp[nw].fi, dp[nw].se - need));
}
int l = dp[nw].fi + 1, r = d, ans = -1, val = -1;
while(l <= r){
int mid = (l + r) >> 1;
ll cand = get(dp[nw].fi + 1, mid);
if(cand >= need){
ans = mid; r = mid - 1; val = cand;
}else{
l = mid + 1;
}
}
if(ans != -1){
ckmin(dp[i], make_pair(ans, val - need));
}
in[i]--;
if(in[i] == 0){
q.push(i);
}
}
}
for(int i = 1; i <= n; i++){
cout << ((dp[i].fi >= 1e9) ? -1 : dp[i].fi) << "\n";
}
return(0);
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2luY2x1ZGU8ZnN0cmVhbT4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBzeihhKSAoaW50KWEuc2l6ZSgpCiNkZWZpbmUgVElNRSAgKDEuMCAqIGNsb2NrKCkgLyBDTE9DS1NfUEVSX1NFQykKI2RlZmluZSBsbCBsb25nIGxvbmcKI2RlZmluZSBpbnQgbG9uZyBsb25nCiNkZWZpbmUgcGIgcHVzaF9iYWNrCiNkZWZpbmUgZm9ycihpLCBhLCBiKSBmb3IoaW50IGkgPSBhOyBpIDwgYjsgaSsrKQojZGVmaW5lIGRvcnIoaSwgYSwgYikgZm9yKGludCBpID0gYTsgaSA+PSBiOyBpLS0pCiNkZWZpbmUgbGQgbG9uZyBkb3VibGUKI2RlZmluZSB2dCB2ZWN0b3IKI2luY2x1ZGU8ZnN0cmVhbT4KI2RlZmluZSBmaSBmaXJzdAojZGVmaW5lIHNlIHNlY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PiBrOwogICAgZm9ycihpLCAwLCBrKXsKICAgICAgICBjaW4gPj4gYVtpXTsgZGlzW2FbaV1dID0gMDsgcHEucHVzaCh7ZGlzW2FbaV1dLCBhW2ldfSk7CiAgICB9CiAgIGNpbiA+PiBkOwogICAgZm9yKGludCBpID0gMTsgaSA8PSBkOyBpKyspewogICAgICAgIGNpbiA+PiB4W2ldOyB1cFtpXVswXSA9IHhbaV07CiAgICB9CiAgICBmb3IoaW50IGkgPSAxOyBpIDwgMjA7IGkrKyl7CiAgICAgICAgZm9yKGludCBqID0gMTsgaiArICgxIDw8IGkpIC0gMSA8PSBkOyBqKyspewogICAgICAgICAgICB1cFtqXVtpXSA9IG1heCh1cFtqXVtpIC0gMV0sIHVwW2ogKyAoMSA8PCAoaSAtIDEpKV1baSAtIDFdKTsKICAgICAgICB9CiAgICB9CiAgICB3aGlsZSghcHEuZW1wdHkoKSl7CiAKICAgICAgICBhdXRvIFtkZCwgdV0gPSBwcS50b3AoKTsgcHEucG9wKCk7CiAgICAgICAgaWYoZGlzW3VdICE9IGRkKWNvbnRpbnVlOwogICAgICAgIGZvcihhdXRvIFt2LCB3XTogYWRqW3VdKXsKICAgICAgICAgICAgaWYoZGlzW3ZdID4gZGlzW3VdICsgdyl7CiAgICAgICAgICAgICAgICBkaXNbdl0gPSBkaXNbdV0gKyB3OyAKICAgICAgICAgICAgICAgIHBxLnB1c2goe2Rpc1t2XSwgdn0pOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQogICAgZm9yKGludCBpID0gMTsgaSA8PSBuOyBpKyspewogICAgICAgIC8vY291dCA8PCBkaXNbaV0gPDwgIiAiOwogICAgICAgIGZvcihhdXRvIFt2LCB3XTogYWRqW2ldKXsKICAgICAgICAgICAgaWYoZGlzW2ldICsgdyA9PSBkaXNbdl0pewogICAgICAgICAgICAgICAgZ1tpXS5wYih2KTsgaW5bdl0rKzsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIGZvcihpbnQgaSA9IDE7IGkgPD0gbjsgaSsrKXsKICAgICAgICBkcFtpXSA9IG1ha2VfcGFpcigxZTksIDApOwogICAgfQogICAgcXVldWU8aW50PnE7CiAgICBmb3IoaW50IGkgPSAxOyBpIDw9IG47IGkrKyl7CiAgICAgICAgaWYoaW5baV0gPT0gMCAmJiBkaXNbaV0gPCAxZTE4KXsKICAgICAgICAgICAgZHBbaV0gPSBtYWtlX3BhaXIoMCwgMCk7CiAgICAgICAgICAgIHEucHVzaChpKTsKICAgICAgICB9CiAgICB9CiAKICAgIHdoaWxlKCFxLmVtcHR5KCkpewogICAgICAgIGludCBudyA9IHEuZnJvbnQoKTsgcS5wb3AoKTsKIAogICAgICAgIGZvcihhdXRvIGk6IGdbbnddKXsKICAgICAgICAgICAgbGwgbmVlZCA9IGRpc1tpXSAtIGRpc1tud107CiAKICAgICAgICAgICAgaWYoZHBbbnddLnNlID49IG5lZWQgJiYgZHBbbnddLmZpICE9IDFlOSl7CiAgICAgICAgICAgICAgICBja21pbihkcFtpXSwgbWFrZV9wYWlyKGRwW253XS5maSwgZHBbbnddLnNlIC0gbmVlZCkpOwogICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpbnQgbCA9IGRwW253XS5maSArIDEsIHIgPSBkLCBhbnMgPSAtMSwgdmFsID0gLTE7CiAgICAgICAgICAgICAgICB3aGlsZShsIDw9IHIpewogICAgICAgICAgICAgICAgICAgIGludCBtaWQgPSAobCArIHIpID4+IDE7CiAgICAgICAgICAgICAgICAgICAgbGwgY2FuZCA9IGdldChkcFtud10uZmkgKyAxLCBtaWQpOwogICAgICAgICAgICAgICAgICAgIGlmKGNhbmQgPj0gbmVlZCl7CiAgICAgICAgICAgICAgICAgICAgICAgIGFucyA9IG1pZDsgciA9IG1pZCAtIDE7IHZhbCA9IGNhbmQ7CiAgICAgICAgICAgICAgICAgICAgfWVsc2V7CiAgICAgICAgICAgICAgICAgICAgICAgIGwgPSBtaWQgKyAxOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmKGFucyAhPSAtMSl7CiAKICAgICAgICAgICAgICAgICAgICBja21pbihkcFtpXSwgbWFrZV9wYWlyKGFucywgdmFsIC0gbmVlZCkpOwogICAgICAgICAgICAgICAgfQogCiAKICAgICAgICAgICAgaW5baV0tLTsKICAgICAgICAgICAgaWYoaW5baV0gPT0gMCl7CiAgICAgICAgICAgICAgICBxLnB1c2goaSk7CiAgICAgICAgICAgIH0KIAogICAgfQogICAgfQogICAgZm9yKGludCBpID0gMTsgaSA8PSBuOyBpKyspewogICAgICAgIGNvdXQgPDwgKChkcFtpXS5maSA+PSAxZTkpID8gLTEgOiBkcFtpXS5maSkgPDwgIlxuIjsKICAgIH0KICAgIHJldHVybigwKTsKfQ==