#if defined(__GNUC__)
#include <bits/stdc++.h>
#define __int32 __int32_t
// __GNUC__
#else
#include "bits/stdc++.h"
#endif
using namespace std;

#define int long long

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); ++(i))
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); ++(i))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) std::sort(ALL(x))
#define RSORT(x) std::sort(ALL(x), greater<decltype(x)::value_type>())
#define RSORT2(x, T) std::sort(ALL(x), greater<T>())
#define REVERCE(x) std::reverce(ALL(x))
#define ACM(x, y) std::accumulate(ALL(x), y)

#define INT_POW(x, y) [](int a, int b) -> int {int c = a; REP(i, b - 1){c *= a;} return c;}(x, y)
#define INT_POWM(x, y, m) [](int a, int b, int m) -> int {int c = a; REP(i, b - 1){c *= a; c %= m;} return c;}(x, y, m)
#define FCT(x) [](int a) -> int {int r = 1; REP(i, a){r *= i;} return r;}(x)

// デバッグ用
#define PUT_LIST(x, y) std::copy(ALL(x), std::ostream_iterator<decltype(x)::value_type>(std::cout, y))

struct edge {
	int to;
	int cost;
	bool visit = false;
};

itn main() {
	std::ios::sync_with_stdio(false);

	int n;

	cin >> n;

	vector<int> a(n - 1), b(n - 1), c(n - 1);

	REP(i, n - 1) {
		cin >> a[i] >> b[i] >> c[i];
	}

	int q, k;

	cin >> q >> k;

	vector<vector<edge>> tree(n);

	REP(i, n - 1) {
		tree[a[i] - 1].push_back(edge{ b[i] - 1, c[i] });
		tree[b[i] - 1].push_back(edge{ a[i] - 1, c[i] });
	}
	
	vector<int> cost(n, (int)1e15);
	queue<int> stock;

	cost[k - 1] = 0;
	stock.push(k - 1);

	while (!stock.empty()) {
		for (auto &v : tree[stock.front()]) {
			if (v.visit) {
				continue;
			}
			else {
				cost[v.to] = min(cost[v.to], cost[stock.front()] + v.cost);
				v.visit = true;
				stock.push(v.to);
			}
		}

		stock.pop();
	}

	vector<int> x(q), y(q);

	REP(i, q) {
		cin >> x[i] >> y[i];
	}
	REP(i, q) {
		cout << cost[x[i] - 1] + cost[y[i] - 1] << '\n';
	}

	return 0;
}
