#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))

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

const int mod = 1000000007;

struct edge {
    int to;
    long cost;
};

const int MAX_V = 100005;
vector<edge> G[MAX_V];

class LCA {
public:
    long V, logV;
    vector<long> depth, len;
    vector<vector<long> > parent;
    
    LCA(long V) {
        this->V = V;
        logV = 0;
        while (V > (1LL<<logV)) logV++;
        this->depth = vector<long>(V);
        this->len = vector<long>(V);
        this->parent = vector<vector<long> >(logV, vector<long>(V));
    }
    
    void init(long v, long par, long d, long l) {
        depth[v] = d;
        parent[0][v] = par;
        len[v] = l;
        for (int i = 0; i < (int)G[v].size(); i++) {
            long w = G[v][i].to;
            long lc = G[v][i].cost;
            if (w == par) continue;
            init(w, v, d+1, lc + l);
        }
    }
    
    void build() {
        for (int k = 0; k + 1 < logV; k++) {
            for (int v = 0; v < V; v++) {
                if (parent[k][v] < 0) parent[k+1][v] = -1;
                else parent[k+1][v] = parent[k][parent[k][v]];
            }
        }
    }
    
    long query(long u, long v) {
        if (depth[u] > depth[v]) swap(u, v);
        for (int k = 0; k < logV; k++) {
            if ((depth[v] - depth[u]) >> k & 1)
                v = parent[k][v];
        }
        if (u == v) return u;
        
        for (int k = logV-1; k >= 0; k--) {
            if (parent[k][u] != parent[k][v]) {
                u = parent[k][u];
                v = parent[k][v];
            }
        }
        return parent[0][u];
    }
};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  rep(i, n-1) {
    int a, b;
    long c;
    cin >> a>>  b>>c;
    a--;
    b--;
    G[a].push_back({b, c});
    G[b].push_back({a, c});
  }

  LCA lca(n);
  lca.init(0, -1, 0, 0);
  lca.build();

  int q, k;
  cin >> q >> k;
  k--;

  rep(i, q) {
    int x, y;
    cin >> x>>y;
    x--;y--;
    long z1 = lca.query(x, k);
    long ret1 = lca.len[x] + lca.len[k] - 2 * lca.len[z1];
    long z2 = lca.query(k, y);
    long ret2 = lca.len[k] + lca.len[y] - 2 * lca.len[z2];
    cout << ret1+ret2 << endl;
  }
}


Measured memory_bytes: 31600