#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define double long double
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
vector<vector<pll> >G(100010);
vector<pll>par(100010);
vector<ll>dis(100010);
void dfs(ll i,ll p,ll d,ll def){
    par[i].first=p;
    par[i].second=def-1;
    dis[i]=d;
    rep(j,G[i].size()){
        if(G[i][j].first==p)continue;
        dfs(G[i][j].first,i,d+G[i][j].second,def+1);
    }
}
ll LCA(ll x,ll y){
    ll s=par[x].second+1;
    ll t=par[y].second+1;
    if(t>s){
        return LCA(x,par[y].first);
    }else if(t<s){
        return LCA(par[x].first,y);
    }else{
        if(x==y)return x;
        else return LCA(par[x].first,par[y].first);
    }
}
int main(){
    ll n;
    cin>>n;
    rep(i,n-1){
        ll u,v,w;
        cin>>u>>v>>w;
        G[u].pb(mp(v,w));
        G[v].pb(mp(u,w));
    }
    dfs(0LL,(ll)-1,0LL,0LL);
    ll q;
    cin>>q;
    while(q){
        ll x,y,z;
        cin>>x>>y>>z;
        cout<<dis[x]+dis[y]+dis[z]-dis[LCA(x,y)]-dis[LCA(y,z)]-dis[LCA(z,x)]<<'\n';
        q--;
    }
}