#include <iostream>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <cstring>
#include <iomanip>
#include <set>
#include <bitset>
#define int long long
using namespace std;
using ll = long long;
using pii = pair<ll,ll>;
using piii = tuple<int,int,int>;
#define endl '\n'
#define f first
#define s second
#define all(x) begin(x),end(x)
int const INF = 1e18+10;
int const N = 5010;
int walk[N][35];
vector<pii> adj[N];
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);
memset(walk,-1,sizeof walk);
int n;cin >> n;
int m;cin >> m;
int k;cin >> k;
priority_queue<piii,vector<piii>,greater<piii>> pq;//weight, pos, ticket
for(int i{};i < k;i++){
int t;cin >> t;
pq.emplace(0,t,0);
walk[t][0] = 0;
}
for(int i{};i < m;i++){
int a,b,c;cin >> a >> b >> c;
adj[b].emplace_back(a,c);
}
while(!pq.empty()){
auto [cost,pos,mask] = pq.top();pq.pop();
if(walk[pos][mask] < cost) continue;
for(auto [k,w]:adj[pos]){
if(walk[k][mask] == -1 || walk[k][mask] > cost+w){
walk[k][mask] = cost+w;
pq.emplace(cost+w,k,mask);
}
for(int j{};j < 5;j++){
if(!((mask>>j)&1)){
//cout << pos << " " <<j << endl;
if(walk[k][mask|(1<<j)] == -1 || walk[k][mask|(1<<j)] > cost+((w/10)*(9-j))){
walk[k][mask|(1<<j)] = cost+((w/10)*(9-j));
pq.emplace(walk[k][mask|(1<<j)],k,mask|(1<<j));
}
}
}
}
}
int q;cin >> q;
for(int i{};i < q;i++){
int st;cin >> st;
int ticket[5];
int banned = 0;
for(int i{};i < 5;i++){
cin >> ticket[i];
if(ticket[i] == -1) banned |= (1<<i);
}
int ans = INF;
for(int i{};i < (1<<5);i++){
if(i&banned) continue;
if(walk[st][i] == -1) continue;
int curcost = walk[st][i];
for(int j{};j < 5;j++){
if((i>>j)&1){
curcost += ticket[j];
}
}
ans = min(ans,curcost);
}
if(ans == INF) cout << -1 << endl;
else cout << ans << endl;
}
}