#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

#define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) ;
#define LINE     ;
#define dumpV(v);
#define STOP     ;
#endif
#define mp make_pair

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fi<<", "<<a.se<<')';
    return out;
  }
}


const int MAX_N = 1e5+10;
const int MAX_M = 5e5+10;

int t[MAX_N];
using Edge = pair<int, ll>; // to, cost
vector<Edge> es[MAX_N];

using State = pair<ll, pii>; // cost, day, population
State StateINF = State(1e18, pii(1e9, 1e9));

bool chMin(State& a, const State& b) {
    if(a <= b) return false;
    a = b;
    return true;
}

State d[MAX_N];

int from[MAX_N]; // 経路復元

int A[MAX_N][30];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    rep(i, n) cin >> t[i];
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        --a;
        --b;
        es[a].pb({b, (ll)c});
        es[b].pb({a, (ll)c});
    }
    from[0] = -1;
    {
        rep(i, n) d[i] = StateINF;
        int root = 0;
        using P = pair<State, int>;
        priority_queue<P, vector<P>, greater<P> > q;
        d[root] = {0LL, {0, -1}};
        q.push({d[root], root});
        while (!q.empty()) {
            auto p = q.top(); q.pop();
            int prv = p.se;
            const auto state = p.fi;
            if (d[prv] < p.fi) continue;
            for (auto& e : es[prv]) {
                int to = e.fi;
                auto nState = state;
                nState.fi += e.se;
                nState.se.fi++;
                nState.se.se = t[prv];

                if (chMin(d[to], nState)) {
                    q.push({d[to], to});
                    from[to] = prv;
                }
            }
        }
    }
    rep(i, MAX_N) rep(j, 30) A[i][j] = -1;
    rep(j, 30) rep(i, n) {
        if(j == 0) A[i][j] = from[i];
        else if(A[i][j-1] != -1) A[i][j] = A[A[i][j-1]][j-1];
    }
    // rep(i, n) {
    //     cout << i << " " << d[i].fi << " " << d[i].se.fi << " " << d[i].se.se  << " " << from[i] << " " << A[i][0] <<endl;
    // }
    // return 0;
    // LINE;
    int k;
    cin >> k;
    rep(_, k) {
        int x, D, p;
        cin >> x >> D >> p;
        --x;
        auto s = d[x];
        int day = s.se.fi;
        ll cost = s.fi;
        if(day <= D) cout << max(0LL, cost - p) << '\n';
        else {
            int now = x;
            while(d[now].se.fi > D) {
                // dump(mp(now, d[now].se.fi));
                // dump(D);
                if(A[now][0] == -1) break;
                rep(i, 20) {
                    int to = A[now][i];
                    if(to == -1) {
                        now = A[now][i-1];
                        break;
                    }
                    if(d[to].se.fi < D) {
                        now = A[now][i-1];
                        break;
                    } 
                }
            }
            assert(now >= 0 && d[now].se.fi == D);
            ll dif = cost - d[now].fi;
            // cout << now << endl;
            cout << dif + max(0LL, d[now].fi - p) << '\n';
            // LINE;
        }
    }
    return 0;
}


Measured memory_bytes: 44388