///============================================================================///
///                                                                            ///
///                            IT'S ME                                         ///
///                         BISHAL GAUTAM                                      ///
///                  CSE,JAHANGIRNAGAR UNIVERSITY,DHAKA                        ///
///               "Follow Excellence..Success will chase U"                    ///
///                                                                            ///
///============================================================================///
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define X first
#define Y second
#define nl printf("\n")
#define SZ(x) (int)(x.size())
#define pb(x) push_back(x)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define mpp make_pair

///==Scanning====///
#define S(a) scanf("%d",&a)
#define P(a) printf("%d",a)
#define SL(a) scanf("%lld",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define SL2(a,b) scanf("%lld%lld",&a,&b)
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)

///==Arr,Vec Functions==///
#define all(v) v.begin(),v.end()
#define CLR(a) memset(a,0,sizeof(a))
#define SET(a) memset(a,-1,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define MAX(a) (*max_element(all(a)))
#define MIN(a) (*min_element(all(a)))
#define fv(i,v) for(int i=0;i<(int)v.size();i++)
#define fr(i,a,n) for(int i=a;i<=n;i++)
#define rf(i,n,a) for(int i=n;i>=a;i--)

///===Some Useful====///
#define OnBit(a) __builtin_popcountll(a)
#define LB(v,k) lower_bound(v.begin(),v.end(),k)
#define _cin ios_base::sync_with_stdio(0),cin.tie(0)
#define dbg(x) cerr<<__LINE__<< ":: "<<#x<<"= "<<x<<endl
#define fi(n) for(__typeof(n.begin()) it=n.begin();it!=n.end();it++)
#define IO freopen("A.in","r",stdin),freopen("Out.out","w",stdout)
using namespace std;

///===TypeDefs=====///
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pii> vii;

///===Number Theory===///
//template< class T > inline T SQR(T a) { return a*a; }
//template< class T > inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/_gcd(a,b))*b;}
//template<typename T> T POW(T b,T p) {T r=1; while(p){if(p&1)r=(r*b);b=(b*b);p>>=1;}return r;}
//template<typename T> T BigMod(T b,T p,T m) {T r=1; while(p){if(p&1)r=(r*b)%m;b=(b*b)%m;p>>=1;}return r;}
//template<typename T> T ModInverse(T n,T m) { return BigMod(n,m-2,m); }
//
/////==GeoMetry=========///
//double DEG(double x) { return (180.0*x)/(PI);}
//double RAD(double x) { return (x*(double)PI)/(180.0);}
//template<typename T> double DIS(T a,T b){ return sqrt((double)( SQR(a.X-b.X)+ SQR(a.Y-b.Y))); }
//template<typename T> T ANGLE(T a,T b){ return atan( double(a.Y-b.Y) / double(a.X-b.X));}
//template<typename T> int isLeft(T a,T b,T c) { return (c.X-a.X)*(b.Y-a.Y)-(b.X-a.X)*(c.Y-a.Y); }
//
/////===IO-Related===///
//template< class T > void prnt(T v) { fv(i,v) {if(!i)cout<<v[i];else cout<<" "<<v[i];} cout<<endl; }
//template< class T > void BIN(T n) { if(!n){nl;return;}BIN(n/2);cout<<(n%2); }
//template<typename T> T in(){ char ch; T n = 0; bool ng = false; while (1) { ch = getchar(); if (ch == '-') { ng = true; ch = getchar(); break;} if (ch>='0' && ch<='9') break; } while (1) { n = n*10 + (ch - '0'); ch = getchar(); if (ch<'0' || ch>'9') break; } return (ng?-n:n); }

///====Some-Stuff===///
/// atoi( str.c_str() ); // char string to int
/// sprintf(str,"%d",num);// num to char string
///int month[]={-1,31,28,31,30,31,30,31,31,30,31,30,31}; //Not Leap Year
///int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
///int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 Direction
///int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction

/**************************************************************************************
* ///////////////////////////////////////////////////////////////////////////////////*
*************************************************************************************/

///==========CONSTANTS==============///
/// Digit 0123456789*#@%&^$"- ///
#define inf 2000000000
#define MD 1000000007
#define eps 1e-9
#define MX 200002
///================================///

int n,lg,tmm,col[MX],St[MX],Ed[MX],L[MX],T[MX],P[20][MX];
ll Dis[20][MX],LD[MX];
vector<int>G[MX+2],C[MX+2];

void Dfs(int u,int p,int l) {
    L[u]=l;
    T[u]=p;
    St[u]=++tmm;
    fv(i,G[u]) {
        int v=G[u][i];
        if(v==p)continue;
        Dis[0][v]=C[u][i];
        LD[v]=C[u][i]+LD[u];
        Dfs(v,u,l+1);
    }
    Ed[u]=++tmm;
}

void PrePar( ) {
    for(int i=1; i<=n; i++)P[0][i]=T[i];
    for(int i=1; 1<<i<=n ; i++) { ///Length
        for(int j=1; j<=n; j++) { /// Node ID
            if( P[i-1][j]==-1 )continue;
            Dis[i][j]= Dis[i-1][j]+ Dis[i-1][ P[i-1][j] ];
            P[i][j]= P[i-1][ P[i-1][j] ];
        }
    }
}

ll dis;
int Kth(int x,int k) {
    for(int i=18; i>=0; i--) {
        if( (1<<i) <=k ) {
            dis+=Dis[i][x];
            x=P[i][x];
            k-=(1<<i);
        }
    }
    return x;
}

int LCA(int x,int y) {
    if( L[x]<L[y] ) swap(x,y);
    int k=(L[x]-L[y]);
    x=Kth(x,k);
    if(x==y) return x;
    for(int i=18; i>=0; i--) {
        if( P[i][x]!=P[i][y] ) {
            dis+=Dis[i][x];
            dis+=Dis[i][y];
            x=P[i][x];
            y=P[i][y];
        }
    }
    dis+=Dis[0][x];
    dis+=Dis[0][y];
    return T[x];
}

void Init() {
    fr(i,0,n)G[i].clear(),C[i].clear();
    CLR(Dis);
    CLR(L);
    CLR(LD);
    SET(P);
    SET(T);
}

int main() {
    int tc,cs=1,m,i,j,q,k,l,x,y,z,op;
    //S(tc);
    tc=1;
    while(tc--) {
        S(n);
        Init( );
        fr(i,1,n-1) {
            S2(x,y);
            S(z);
            G[x].pb(y);
            G[y].pb(x);
            C[x].pb(z);
            C[y].pb(z);
        }

        tmm=0;
        Dfs(1,-1,1);
        /// Preprocess for LCA;
        PrePar( );

        S2(q,k);

        //cout<< "K : "<<k<<endl;

        while(q--) {
            S2(x,y);
            dis=0;
            ll ans=0;
            LCA(x,k);
            ans=dis;
            dis=0;
            LCA(k,y);
            printf("%lld\n",ans+dis);

        }
    }
    return 0;
}


Measured memory_bytes: 77312