// Original C++ solution (slower):
#include "bits/stdc++.h"

using namespace std;

typedef long long lint;

typedef pair<lint,lint> P;

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

#define INF LLONG_MAX

#define MAX_V 100005

struct edge{lint to,cost;};

lint n;

vector<edge> vec[MAX_V];

lint d[MAX_V];

void dijkstra(lint k);

void dijkstra2(lint k);

signed main(){

    cin>>n;

    rep(i,n-1){  

        lint a,b,c;

        cin>>a>>b>>c;

        a--;

        b--;

        vec[a].push_back({b,c});

        vec[b].push_back({a,c});

    }          

    lint q,k;

    cin>>q>>k;

    k--;

    dijkstra2(k);

    rep(i,q){

        lint x,y;

        cin>>x>>y; 

        x--;

        y--;

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

    }

    return 0;

}

void dijkstra(lint k){

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

    fill(d,d+n,INF);

    d[k]=0;

    que.push(P(0,k));

    while(!que.empty()){

        P p=que.top();

        que.pop();

        lint v= p.second;

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

        for(lint i=0;i<vec[v].size();i++){

            edge temp=vec[v][i];

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

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

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

            }

        }

    }

}



void dijkstra2(lint k){

    queue<P>que;

    fill(d,d+n,INF);

    d[k]=0;

    que.push(P(0,k));

    while(!que.empty()){

        P p=que.front();

        que.pop();

        lint v= p.second;

        for(lint i=0;i<vec[v].size();i++){

            edge temp=vec[v][i];

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

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

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

            }

        }

    }

}


// Optimized solution to the same problem (faster):
#include "bits/stdc++.h"

using namespace std;

const int MOD = 1e9 + 7;

typedef long long lint;

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

#define repi(i, k, n) for (lint i = (k); i < (lint)(n); ++i)

typedef pair<lint, lint> P;

typedef vector<lint> vi;

typedef vector<vi> vvi;

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

#define pb push_back

#define V 100005

struct edge

{

    lint to;

    lint cost;

};

vector<vector<edge>> G;

vi d(V, LLONG_MAX);

void dijstra(lint s)

{

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

    d[s] = 0;

    que.push(P(d[s], s));

    while (!que.empty())

    {

        P q = que.top();

        que.pop();

        lint v = q.second;

        if (q.first > d[v])

        {

            continue;

        }

        rep(i, G[v].size())

        {

            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));

            }

        }

    }

}

int main()

{

    lint n;

    cin >> n;

    G.resize(n);

    rep(i, n - 1)

    {

        lint a, b, c;

        cin >> a >> b >> c;

        a--;

        b--;

        G[a].push_back({b, c});

        G[b].push_back({a, c});

    }

    lint q, k;

    cin >> q >> k;

    k--;

    dijstra(k);

    rep(i, q)

    {

        lint x, y;

        cin >> x >> y;

        x--;

        y--;

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

    }

    return 0;

}

// Fastest known solution for this problem: