#include<iostream>
#include
<cmath>
#include
<vector>
using namespace std;
struct data
{
    
int v,w;
};
data tmp;
vector
<data>tree[50001];
int n,q,a,b,c;
bool v[50001];
int L[100001],E[100001],H[50001],dis[50001];
int dp[100001][21];
void dfs(int t,int dep)
{
    
int i;
    E[
++E[0]]=t;
    L[
++L[0]]=dep;
    H[t]
=E[0];
    
for(i=0;i<tree[t].size();i++)
    {
        
if(!v[tree[t][i].v])
        {
            v[tree[t][i].v]
=1;
            dis[tree[t][i].v]
=dis[t]+tree[t][i].w;
            dfs(tree[t][i].v,dep
+1);
            E[
++E[0]]=t;
            L[
++L[0]]=dep;
        }
    }
    
return ;
}
int check(int a,int b)
{
    
int k=(int)(log((double)(b-a+1))/log(2.0));
    
if(L[dp[a][k]]<L[dp[b-(1<<k)+1][k]])
    {
        
return E[dp[a][k]];
    }
    
else
        
return E[dp[b-(1<<k)+1][k]];
}
void RMQ()
{
    
int i,j,k;
    
for(i=1;i<=2*n-1;i++)
    {
        dp[i][
0]=i;
    }
    
for(k=1;k<=(int)(log((double)(2*n-1))/log(2.0));k++)
    {
        
for(i=1;i+(1<<k)-1<=2*n-1;i++)
        {
            
if(L[dp[i][k-1]]<L[dp[i+(1<<(k-1))][k-1]])
            {
                dp[i][k]
=dp[i][k-1];
            }
            
else
                dp[i][k]
=dp[i+(1<<(k-1))][k-1];
        }
    }
    
return ;
}
int main()
{
    
int i,j;
    
bool flag=0;
    
while(scanf("%d",&n)!=EOF)
    {
        
if(flag==0)
            flag
=1;
        
else
            printf(
"\n");
        memset(v,
0,sizeof(v));
        memset(dis,
0,sizeof(dis));
        E[
0]=0;
        L[
0]=0;
        
for(i=0;i<n;i++)
        {
            tree[i].clear();

        }
        
for(i=1;i<n;i++)
        {
            scanf(
"%d%d%d",&a,&b,&c);
            tmp.v
=b;
            tmp.w
=c;
            tree[a].push_back(tmp);
            tmp.v
=a;
            tmp.w
=c;
            tree[b].push_back(tmp);
        }
        v[
0]=1;
        dfs(
0,1);
        RMQ();
        scanf(
"%d",&q);
        
while(q--)
        {
            scanf(
"%d %d %d",&a,&b,&c);
            
int sum=0;
            
if(H[a]<H[b])
            {
                sum
+=dis[a]-dis[check(H[a],H[b])];
                sum
+=dis[b]-dis[check(H[a],H[b])];
            }
            
else
            {
                sum
+=dis[a]-dis[check(H[b],H[a])];
                sum
+=dis[b]-dis[check(H[b],H[a])];
            }
            
if(H[a]<H[c])
            {
                sum
+=dis[a]-dis[check(H[a],H[c])];
                sum
+=dis[c]-dis[check(H[a],H[c])];
            }
            
else
            {
                
                sum
+=dis[a]-dis[check(H[c],H[a])];
                sum
+=dis[c]-dis[check(H[c],H[a])];
            }
            
if(H[b]<H[c])
            {
                sum
+=dis[b]-dis[check(H[b],H[c])];
                sum
+=dis[c]-dis[check(H[b],H[c])];
            }
            
else
            {
                
                sum
+=dis[b]-dis[check(H[c],H[b])];
                sum
+=dis[c]-dis[check(H[c],H[b])];
            }
            printf(
"%d\n",sum/2);

        }
        
//printf("\n");
    }    
    
//system("pause");
    return 0;
}