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

#include <algorithm>

#include <vector>

#include <string>

#include <queue>

#include <stack>

#include <functional>

#include <map>

#include <set>

#include <cstdio>

#include <cstdlib>

#include <cmath>

using namespace std;



#define INF int(1e9)

#define MOD int(1e9)

#define repi(i,j,n) for (int i = (j); i < (n); ++i)

#define rep(i,n) repi(i,0,n)



inline void init() {

    cin.tie(0);

    ios::sync_with_stdio(false);

}



struct edge {

  int v, cost;

  edge() {}

  edge(int v, int cost) : v(v), cost(cost) {}

};



vector<edge> g[100005];

long long d[100005], dk[100005];

int V, E, k;



inline void bfs(int s) {

    queue<pair<long long, long long> > que;

    bool used[100005] = {false};

    used[s] = true;

    d[s] = 0;

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



    while (!que.empty()) {

        pair<long long, long long> p = que.front();

        que.pop();



        int v = p.second;

        int size_ = g[v].size();



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

            if (!used[g[v][i].v]) {

                used[g[v][i].v] = true;

                d[g[v][i].v] = p.first + g[v][i].cost;

                //cout << d[g[v][i].v] << endl;

                if (g[v][i].v == k) return;

                que.push(make_pair(p.first + g[v][i].cost, g[v][i].v));

            }

        }

    }

}



inline void bfsk(int s) {

    queue<pair<long long, long long> > que;

    bool used[100005] = {false};

    used[s] = true;

    dk[s] = 0;

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



    while (!que.empty()) {

        pair<long long, long long> p = que.front();

        que.pop();



        int v = p.second;

        int size_ = g[v].size();



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

            if (!used[g[v][i].v]) {

                used[g[v][i].v] = true;

                dk[g[v][i].v] = p.first + g[v][i].cost;

                //cout << dk[g[v][i].v] << endl;

                que.push(make_pair(p.first + g[v][i].cost, g[v][i].v));

            }

        }

    }

}



int main(void) {

    init();

    cin >> V;

    E = V - 1;

    int a, b, c;



    rep(i,V-1) {

        cin >> a >> b >> c;

        a--;

        b--;

        g[a].push_back(edge(b, c));

        g[b].push_back(edge(a, c));

    }



    int q, x, y;

    cin >> q >> k;

    k--;

    bfsk(k);

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

        cin >> x >> y;

        x--; y--;

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

    }

    



    return 0;

}

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

#include <algorithm>

#include <string>

#include <map>

#include <queue>

#include <vector>

#include <cstring>



using std::cin;

using std::cout;

using std::cerr;

using std::endl;



struct Edge {

  int to, cost;



  Edge() {}

  Edge(int to, int cost) : to(to), cost(cost) {}

};



void bfs(std::vector<std::vector<Edge> >& g, long long d[], int k) {

  std::fill(d, d + 100000, (long long)(1e15));



  d[k] = 0;



  std::priority_queue<std::pair<long long, int> > que; // cost, vertex

  que.push({0, k});



  while (!que.empty()) {

    auto p = que.top();

    que.pop();



    for (auto nextv : g[p.second]) {

      if (d[nextv.to] <= p.first + nextv.cost) {

	continue;

      }



      d[nextv.to] = p.first + nextv.cost;

      que.push({d[nextv.to], nextv.to}); 

    }

  }



}



int main() {

  int N, Q, K;

  long long d[100001];

  std::vector<std::vector<Edge> > g;



  cin >> N;

  g.resize(N);



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

    int a, b, c;

    cin >> a >> b >> c, a--, b--;



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

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

  }



  cin >> Q >> K, K--;



  bfs(g, d, K);



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

    int x, y;

    cin >> x >> y, x--, y--;



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

  }



  return 0;

}


// Fastest known solution for this problem: