// Original C++ solution (slower):
#include <algorithm>

#include <bitset>

#include <complex>

#include <deque>

#include <exception>

#include <fstream>

#include <functional>

#include <iomanip>

#include <ios>

#include <iosfwd>

#include <iostream>

#include <istream>

#include <iterator>

#include <limits>

#include <list>

#include <locale>

#include <map>

#include <memory>

#include <new>

#include <numeric>

#include <ostream>

#include <queue>

#include <set>

#include <sstream>

#include <stack>

#include <stdexcept>

#include <streambuf>

#include <string>

#include <typeinfo>

#include <utility>

#include <valarray>

#include <vector>



#define REP(i, m, n) for(int i=int(m);i<int(n);i++)

#define EACH(i, c) for (auto &(i): c)

#define all(c) begin(c),end(c)

#define EXIST(s, e) ((s).find(e)!=(s).end())

#define SORT(c) sort(begin(c),end(c))

#define pb emplace_back

#define MP make_pair

#define SZ(a) int((a).size())



//#define LOCAL 1

#ifdef LOCAL

#define DEBUG(s) cout << (s) << endl

#define dump(x)  cerr << #x << " = " << (x) << endl

#define BR cout << endl;

#else

#define DEBUG(s) do{}while(0)

#define dump(x) do{}while(0)

#define BR

#endif



//改造

typedef long long int ll;

using namespace std;





//ここから編集する





struct edge {

    int to;

    ll cost;

};

typedef pair<ll, int> P;



int V;

vector<edge> G[100005];

ll INF = 922337203685477580;

ll dd[100005];

void dijkstra(int s) {

    ll dd2[100005];





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

//    fill(d, d + V, INF);

    for(int i = 0; i <= V; i++){

        dd2[i] = INF;

    }

    dd2[s] = 0;

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



    while (!que.empty()) {

        P p = que.top();

        que.pop();

        int v = p.second;

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

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

            edge e = G[v][i];

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

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

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

            }

        }

    }

    for(int i = 0; i <= V; i++){

        dd[i] = dd2[i];

    }



}



int main() {

    int n;

    cin >> n;

    V = n;

    for (int i = 0; i < n - 1; i++) {

        int a, b, c;

        cin >> a >> b >> c;

        edge e;

        e.to = a;

        e.cost = c;

        G[b].push_back(e);

        e.to = b;

        G[a].push_back(e);

    }

    int q, k;

    cin >> q >> k;

    dijkstra(k);

    for (int i = 0; i < q; i++) {

        int x, y;

        cin >> x >> y;

        ll ans;

        ans = dd[x] + dd[y];

        cout << ans << endl;

    }

    return 0;

}


// Optimized solution to the same problem (faster):
#include <algorithm>

#include <bitset>

#include <complex>

#include <deque>

#include <exception>

#include <fstream>

#include <functional>

#include <iomanip>

#include <ios>

#include <iosfwd>

#include <iostream>

#include <istream>

#include <iterator>

#include <limits>

#include <list>

#include <locale>

#include <map>

#include <memory>

#include <new>

#include <numeric>

#include <ostream>

#include <queue>

#include <set>

#include <sstream>

#include <stack>

#include <stdexcept>

#include <streambuf>

#include <string>

#include <typeinfo>

#include <utility>

#include <valarray>

#include <vector>



#define REP(i, m, n) for(int i=int(m);i<int(n);i++)

#define EACH(i, c) for (auto &(i): c)

#define all(c) begin(c),end(c)

#define EXIST(s, e) ((s).find(e)!=(s).end())

#define SORT(c) sort(begin(c),end(c))

#define pb emplace_back

#define MP make_pair

#define SZ(a) int((a).size())



//#define LOCAL 1

#ifdef LOCAL

#define DEBUG(s) cout << (s) << endl

#define dump(x)  cerr << #x << " = " << (x) << endl

#define BR cout << endl;

#else

#define DEBUG(s) do{}while(0)

#define dump(x) do{}while(0)

#define BR

#endif





//改造

typedef long long int ll;

using namespace std;

#define INF (1 << 30)

#define INFl (ll)5e15



//ここから編集する

struct edge{ll to,cost;};

typedef pair<ll,ll> P;//firstは最短距離、secondは頂点の番号



int V;//超点数

vector<vector<edge> > G;//グラフ

vector<ll> d; //最短距離



void dijkstra(int s){

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

    fill(d.begin(),d.end(),INFl);

    d[s] = 0;

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



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

            }

        }

    }



}





int main() {

    int N;

    cin >> N;

    V = N;

    G = vector<vector<edge> >(N+1);

    d = vector<ll>(N+1);



    REP(i,1,N){

        int a,b,c;

        cin >> a >> b >> c;

        edge e;

        e.to = b;

        e.cost = c;

        G[a].push_back(e);

        e.to = a;

        G[b].push_back(e);

    }

    int Q,K;

    cin >> Q >> K;

    dijkstra(K);

    REP(i,0,Q){

        int x,y;

        cin >> x >> y;

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

    }



    return 0;

}


// Fastest known solution for this problem: