// Slower C++ solution:
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)

#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];

#define max3(a,b,c) max(max(a,b),c)

#define min3(a,b,c) min(min(a,b),c)

#define ft first

#define sc second

#define pb push_back

#define lb lower_bound

#define ub upper_bound

#define all(v) (v).begin(),(v).end()

#define mod 1000000007

using namespace std;

typedef long long ll;

template<class T> using V=vector<T>;

using Graph = vector<vector<int>>;

using P=pair<ll,ll>;

typedef unsigned long long ull;

typedef long double ldouble;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

//V,P(大文字)使用不可

const ll max_V=100005;//大きすぎ注意

const ll INF=1000000000000000000;



struct edge{ll to,cost;};



ll N;//頂点数

ll M;

//ll cst[max_V][max_V];

vector<edge> G[max_V];

bool used[max_V];

ll d[max_V];//頂点sからの最短距離



void dijkstra(ll s){

    priority_queue<P,vector<P>,greater<P>> que;

    fill(d,d+N,INF);

    d[s]=0;

    que.push(P(0,s));//pair...first->最短距離、second->頂点



    while(!que.empty()){

        P p=que.top();que.pop();

        ll v=p.second;

        if(d[v]<p.first) continue;

        for(int i=0;i<G[v].size();i++){

            edge e=G[v][i];

            if(d[e.to]>d[v]+e.cost){

                d[e.to]=d[v]+e.cost;

                que.push(P(d[e.to],e.to));

            }

        }

    }

}



signed main(){

    cin>>N;

    rep(i,N-1){

        ll a,b,c;

        cin>>a>>b>>c;

        a--;b--;

        edge s,t;

        s.to=a;s.cost=c;

        t.to=b;t.cost=c;

        G[a].push_back(t);

        G[b].push_back(s);

    }

    ll q,k;

    cin>>q>>k;

    ll Q=q;

    k--;

    dijkstra(k);

    V<ll> ans;

    while(q--){

        ll x,y;

        cin>>x>>y;

        x--;y--;

        ans.pb(d[x]+d[y]);

        //cout<<d[x]+d[y]<<endl;

    }

    for(auto v:ans) cout<<v<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 3.9034208342105736x):
#include <bits/stdc++.h>

#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];

#define ft first

#define sc second

#define pb push_back

#define lb lower_bound

#define ub upper_bound

#define all(v) (v).begin(),(v).end()

#define LB(a,x) lb(all(a),x)-a.begin()

#define UB(a,x) ub(all(a),x)-a.begin()

#define mod 1000000007

#define FS fixed<<setprecision(15)

using namespace std;

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)

const double pi=3.141592653589793;

template<class T> using V=vector<T>;

using Graph = vector<vector<int>>;

using P=pair<ll,ll>;

typedef unsigned long long ull;

typedef long double ldouble;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

template<class T> inline void out(T a){ cout << a << '\n'; }



const ll INF=1e18;



struct edge{ll to,cost;};





struct PP{

    ll min_d,vert;

};



bool operator> (const PP &p1, const PP &p2){

    return p1.min_d > p2.min_d;

};





class Dijkstra{

public:

    ll n;//頂点数,辺数

    V<V<edge>> G;

    V<ll> d;

    V<ll> pr;



    explicit Dijkstra(ll sz_n){

        n=sz_n;

        G.resize(sz_n);

        d.resize(sz_n);

        pr.resize(sz_n);

    }



    void add_edge(ll from,ll to,ll cost){

        G[from].push_back((edge){to,cost});

        G[to].push_back((edge){from,cost});//有向辺の場合は削除

    }



    void exe(ll s){//頂点sからの最短距離

        priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> que;

        rep(i,n) d[i]=INF;

        d[s]=0;

        que.push(make_pair(0,s));//pair...first->最短距離、second->頂点



        while(!que.empty()){

            pair<ll,ll> p=que.top();que.pop();

            ll v=p.second;

            if(d[v]<p.first) continue;

            for(int i=0;i<(int)G[v].size();i++){

                edge e=G[v][i];

                if(d[e.to]>d[v]+e.cost){

                    d[e.to]=d[v]+e.cost;

                    que.push(make_pair(d[e.to],e.to));

                    pr[e.to]=v;

                }

            }

        }

    }



    ll dist_to(ll t){

        return d[t];

    }



    //頂点tへの最短路

    vector<ll> get_path(ll t){

        vector<ll> path;

        for(;t!=-1;t=pr[t]) path.push_back(t);//tがsになるまでprev[t]をたどっていく

        reverse(all(path));

        return path;

    }



};





int main(){

    cin.tie(0);ios::sync_with_stdio(false);

    ll n;

    cin>>n;

    Dijkstra ds(n);

    rep(i,n-1){

        ll a,b,c;

        cin>>a>>b>>c;

        a--;b--;

        ds.add_edge(a,b,c);

    }

    int Q;ll k;

    cin>>Q>>k;

    k--;

    ds.exe(k);

    while(Q--){

        ll x,y;

        cin>>x>>y;

        x--;y--;

        out(ds.dist_to(x)+ds.dist_to(y));

    }

}