#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <cmath>
#include <cstdlib>
using namespace std;
using ll = long long int;

#define fprintf(...) void(0)

struct Edge {
    ll to, cost;
};

using Graph = vector< vector< Edge > >;

struct Elem {
    ll pos, cost, day;
    bool operator<(const Elem &e) const {
        if(cost != e.cost) return cost > e.cost;
        return day > e.day;
    }
};

const int MAX_N = 100000;
ll N, M, K;
ll popu[MAX_N + 10], x[MAX_N + 10], d[MAX_N + 10], p[MAX_N + 10];

const ll INF = 1LL << 60;
pair< Graph, vector<int> > get_tree(Graph &G) {
    // cost, days
    vector< pair<ll, ll> > state(N, make_pair(INF, INF));

    // population, prev_town
    vector< pair<ll, ll> > pre(N, make_pair(INF, -1));

    priority_queue<Elem> que;
    que.push(Elem{0, 0, 0});
    state[0] = make_pair(0, 0);

    while(que.size()) {
        Elem cur = que.top(); que.pop();
        pair<ll, ll> cur_state = make_pair(cur.cost, cur.day);

        int u = cur.pos;
        if(cur_state > state[u]) continue;

        for(auto e : G[u]) {
            int to = e.to, n_cost = cur.cost + e.cost, n_day = cur.day + 1;

            pair<ll, ll> nxt      = make_pair(n_cost, n_day);
            pair<ll, ll> pop_info = make_pair(popu[u], u);
            if(state[to] > nxt) {
                state[to] = nxt;
                pre[to] = pop_info;
                que.push(Elem{to, n_cost, n_day});
            }
            else if(state[to] == nxt) {
                if(pre[to] > pop_info) {
                    pre[to] = pop_info;
                }
            }
        }
    }

    Graph ret(N);
    vector<int> par(N, -1);
    for(int i=1; i<N; i++) {
        // the parent of i is pre[i].second
        int u = i, v = pre[i].second;

        ll cost_u = state[u].first, cost_v = state[v].first;
        ll diff = llabs(cost_u - cost_v);
        ret[u].push_back(Edge{v, diff});
        ret[v].push_back(Edge{u, diff});
        par[u] = v;
    }
    return make_pair(ret, par);
}

pair< vector<ll>, vector<ll> > get_cost_info(Graph &G) {
    vector<ll> visited(N), sum(N), days(N);

    queue<int> que;
    que.push(0);
    visited[0] = true;

    while(que.size()) {
        int cur = que.front(); que.pop();
        for(auto e : G[cur]) {
            if(visited[e.to]) continue;
            visited[e.to] = true;
            sum[e.to] = sum[cur] + e.cost;
            days[e.to] = days[cur] + 1;
            que.push(e.to);
        }
    }
    return make_pair(sum, days);
}

void solve(Graph &G, vector<int> &par) {
    vector< vector<int> > nxt(N, vector<int>(18, -1));
    vector<ll> acc_cost, days;
    tie(acc_cost, days) = get_cost_info(G);

    // 2^k table
    for(int i=0; i<N; i++) {
        fprintf(stderr, "parent of %d is %d\n", i, par[i]);
        nxt[i][0] = par[i];
    }
    for(int k=1; k<18; k++) {
        for(int i=0; i<N; i++) {
            if(nxt[i][k-1] < 0) continue;
            nxt[i][k] = nxt[ nxt[i][k-1] ][k-1];
        }
    }

    for(int i=0; i<K; i++) {
        ll need_day = days[ x[i] ];
        ll dayA = max(0LL, days[ x[i] ] - d[i]), dayB = need_day - dayA;

        ll costA = acc_cost[ x[i] ];

        // get costB
        ll rest = dayA, cur = x[i];
        for(int k=0; k<18; k++) {
            if(rest >> k & 1) {
                cur = nxt[cur][k];
            }
        }

        ll costB = acc_cost[ cur ];

        fprintf(stderr, "dayA = %lld, dayB = %lld, costA = %lld, costB = %lld\n", dayA, dayB, costA, costB);

        ll ans = costA - costB + max(0LL, costB - p[i]);
        printf("%lld\n", ans);
    }
}

int main() {
    scanf("%lld%lld", &N, &M);
    for(int i=0; i<N; i++) {
        scanf("%lld", &popu[i]);
    }

    Graph G(N);
    for(int i=0; i<M; i++) {
        int a, b, c; scanf("%d%d%d", &a, &b, &c);
        a--; b--;
        G[a].push_back(Edge{b, c});
        G[b].push_back(Edge{a, c});
    }

    scanf("%lld", &K);
    for(int i=0; i<K; i++) {
        scanf("%lld%lld%lld", &x[i], &d[i], &p[i]);
        x[i]--;
    }

    Graph H; vector<int> par;

    fprintf(stderr, "get tree!\n");
    tie(H, par) = get_tree(G);

    fprintf(stderr, "solve!\n");
    solve(H, par);
    return 0;
}


Measured memory_bytes: 53072