// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



typedef unsigned long long ull;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

typedef pair<double, double> pdd;

const ull mod = 1e9 + 7;

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

const int NMAX = 100005;

vector<pll> graph[NMAX];

bool check[NMAX];

ll dist[NMAX];



void dfs(ll now){

    check[now] = true;

    REP(i, graph[now].size()){

        ll next = graph[now][i].first;

        ll cost = graph[now][i].second;

        if(check[next]==false){

            dist[next] = dist[now] + cost;

            dfs(next);

        }

    }

}



int main(){

    int N;

    cin >> N;

    REP(i, N-1){

        ll a, b, c;

        cin >> a >> b >> c;

        a--;b--;

        graph[a].push_back(make_pair(b, c));

        graph[b].push_back(make_pair(a, c));

    }

    REP(i, N){

        check[i] = false;

        dist[i] = 0;

    }

    ll Q, K;

    cin >> Q >> K;

    dfs(K-1);

    REP(i, Q){

        ll x, y;

        cin >> x >> y;

        x--;y--;

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

    }

    return 0;

}

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

using namespace std;

typedef unsigned long long ull;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

typedef pair<double, double> pdd;

const ll mod = 1e9 + 7;

//const ll mod = 998244353;

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

//debug

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

#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){

os << "(" << v.first << ", " << v.second << ")"; return os;

}

template<class T> ostream& operator << (ostream& os, const vector<T> v){

for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;

}

template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){

for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;

}

string num2bit(ll num, ll len){

    string bit = "";

    REP(i, len){

    bit += char('0'+(num>>i & 1));

    }

    return bit;

}



struct edge{

    ll to, w;

};



using UGraph = vector<vector<int>>;

using Graph = vector<vector<edge>>;



template< typename G >

struct DoublingLowestCommonAncestor {

  // gは無向でOK 根はデフォルトでは0

  // 有向なら根付き木の形で与える

  const G &g;

  vector< int > dep;

  const int LOG;

  vector< vector< int > > table;



  DoublingLowestCommonAncestor(const G &g) : g(g), dep(g.size()), LOG(32 - __builtin_clz(g.size())) {

    table.assign(LOG, vector< int >(g.size(), -1));

  }



  void dfs(int idx, int par, int d) {

    table[0][idx] = par;

    dep[idx] = d;

    for(auto &to : g[idx]) {

      if(to != par) dfs(to, idx, d + 1);

    }

  }



  void build() {

    dfs(0, -1, 0);

    for(int k = 0; k + 1 < LOG; k++) {

      for(int i = 0; i < (int)table[k].size(); i++) {

        if(table[k][i] == -1) table[k + 1][i] = -1;

        else table[k + 1][i] = table[k][table[k][i]];

      }

    }

  }



  int query(int u, int v) {

    if(dep[u] > dep[v]) swap(u, v);

    for(int i = LOG - 1; i >= 0; i--) {

      if(((dep[v] - dep[u]) >> i) & 1) v = table[i][v];

    }

    if(u == v) return u;

    for(int i = LOG - 1; i >= 0; i--) {

      if(table[i][u] != table[i][v]) {

        u = table[i][u];

        v = table[i][v];

      }

    }

    return table[0][u];

  }

};



vector<ll> dist(101010, 0);



void dfs(ll now, ll par, ll d, Graph &G){

    dist[now] = d;

    for(auto e: G[now]){

        if(e.to == par) continue;

        dfs(e.to, now, d+e.w, G);

    }

    return;

}



int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);



    ll N;

    cin >> N;

    //UGraph H(N);

    Graph G(N);

    

    REP(i, N-1){

        ll a, b, c;

        cin >> a >> b >> c;

        a--, b--;

        //H[a].push_back(b);

        //H[b].push_back(a);

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

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

    }



    //DoublingLowestCommonAncestor<UGraph> lca(H);

    //lca.build();



    ll Q, K;

    cin >> Q >> K;

    K--;



    dfs(K, -1, 0, G);



    while(Q--){

        ll x, y;

        cin >> x >> y;

        x--, y--;

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

    }



    return 0;

}