#define TEST_MODE true

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= (int)b; --i)
#define range(i, a, b, c) for (int i = a;             \
                                   c > 0 ? i < b : i > b; \
                                   i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define int long long

#ifdef LOCAL_ENV

#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x)
#define dumpl(x) dump(x) << endl
#else
const bool test = false;
#define dump(x) 
#define dumpl(x)
#endif

#else
const bool test = false;
#define dump(x) 
#define dumpl(x)
#endif

int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

vector<string> split(const string &str, char sep)
{
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep))
	{
		v.push_back(buffer);
	}
	return v;
}

template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
	return accumulate(begin, end, 0ll);
}

template<typename T>
T gcd(T a, T b)
{
	T c;
	while (a != 0) {
		c = a; a = b%a;  b = c;
	}
	return b;
}

template<typename T>
T bit_count(T N) {
	T cnt = 0;
	while (N) {
		if (N & 1) cnt++;
		N >>= 1;
	}
	return cnt;
}

struct Point {
	int y, x;
	bool operator < (const Point& r) {
		if (x < r.x) return true;
		else return false;
	}
};

class Solver {
public:
	int N, Q, K;

	struct Vertex {
		int id, dist;
		bool operator > (const Vertex& r) const {
			return dist > r.dist;
		}
	};

	struct Edge {
		int to, weight;
		Edge(int to, int weight) : to(to), weight(weight) {};
	};

	using Graph = vector<vector<Edge>>;

	using Weight = int;

	Graph g;
	int d[MAX];
	int start_id, goal_id;

	int dijkstra(int start_id) {
		rep(i, MAX) {
			d[i] = INFL;
		}
		d[start_id] = 0;
		priority_queue<Vertex, vector<Vertex>, greater<Vertex>> q;
		Vertex start;
		start.id = start_id;
		start.dist = 0;
		for (q.push(start); !q.empty(); ) {
			Vertex p = q.top(); q.pop();
			for (auto f : g[p.id]) {
				Vertex next_p;
				next_p.id = f.to;
				next_p.dist = p.dist + f.weight;
				if (d[next_p.id] > next_p.dist) {
					d[next_p.id] = next_p.dist;
					q.push(next_p);
				}
			}
		}
		return d[goal_id];
	}

	void solve() {
		cin >> N;
		g.resize(N);
		rep(i, N - 1) {
			int a, b, c;
			cin >> a >> b >> c;
			a--; b--;
			
			g[a].push_back(Edge(b, c));
			g[b].push_back(Edge(a, c));
		}
		//cerr << endl;
		//rep(i, N) {
		//	for (Edge e : g[i]) {
		//		cerr << i + 1 << " ";
		//		cerr << e.to + 1 << " ";
		//		cerr << e.weight << endl;
		//	}
		//}
		cin >> Q >> K;
		K--;
		dijkstra(K);
		//rep(i, N) {
		//	dumpl(d[i]);
		//}
		rep(i, Q) {
			int x, y;
			cin >> x >> y;
			x--; y--;
			cout << d[x] + d[y] << endl;
		}
	}
};

signed main()
{
	srand((unsigned int)time(NULL));
	cout << fixed << setprecision(20);
	auto ptr = new Solver();
	ptr->solve();
	delete ptr;
	//while (true) {
	//	if (cin.eof() == true) break;
	//	auto ptr = new Solver();
	//	ptr->solve();
	//	delete ptr;
	//}
	return 0;
}

Measured memory_bytes: 11888