#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a); i<int(b); ++i)
#define RFOR(i,a,b) for(int i=(b)-1; i>=int(a); --i)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,int(n)+1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
#define al(d) d.begin(),d.end()
#define fill(n) std::setfill('0')<<std::right<<std::setw(n)
#define intmax 2147483647
#define llmax 9223372036854775807
#define mod 1000000007
template <typename T>
using vec = std::vector<T>;
using vi = vec<int>;
using vvi = vec<vi>;
using pii = std::pair<int, int>;
using ll = long long;
using vll = vec<ll>;
using ld = long double;
#define pair(a,b) "("<<a<<","<<b<<")"
#define pairr(a,b,c) "("<<a<<","<<b<<","<<c<<")"

template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(int n){
	vector<T> vec;
	rep(i,n){
		T input;
		cin >> input;
		vec.emplace_back(input);
	}
	return vec;
}

////Graph
using Weight = ll;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;
void add_edge(Graph &g, int a, int b, Weight w = 1){
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1){
	g[a].emplace_back(a, b, w);
}
void init_weighted_graph(Graph &g, int N, int M){
	vector<Edge> empty_Edges;
	g = Graph(N,empty_Edges);
	rep(i,M){
		int a,b,w;
		cin >> a >> b >> w;
		add_edge(g,a-1,b-1,w);
	}
// 例えば
//// 3 3
//// 1 2 1
//// 1 3 1
//// 2 3 3
// から
//// The Adjacency List of
//// G=(V,E) (n=3,m=6)
//// 0: (1,1)(2,1)
//// 1: (0,1)(2,3)
//// 2: (0,1)(1,3)
// を得る．
}
void init_weighted_directed_graph(Graph &g, int N, int M){
	vector<Edge> empty_Edges;
	g = Graph(N,empty_Edges);
	rep(i,M){
		int a,b,w;
		cin >> a >> b >> w;
		add_arc(g,a-1,b-1,w);
	}
}
void show_weighted_graph(const Graph &g){
	int N = g.size();
	int M = 0;
	rep(s,N)
		M += g[s].size();
	cout << "///////////////////////"<<endl;
	cout <<"The Adjacency List of" <<endl<< "G=(V,E) (n="<<N<<","<<"m="<<M<<")"<<endl;
	rep(s,N){
		cout << s << ": ";
		int size = g[s].size();
		rep(t,size)
			cout << pair(g[s][t].dst, g[s][t].weight);
		cout << endl;
	}
	cout << "////////////////////////"<<endl<<endl;
}
// a->bが存在するか
bool is_adj(Graph &g, int a, int b){
	for(auto e: g[a])
		if(b==e.dst)
			return true;
	return false;
}
pair<vec<Weight>,bool> bellmanFord(const Graph &g, int s){
	int n = g.size();
	const Weight inf = numeric_limits<Weight>::max()/8;

	Edges es;
	rep(v,n)
		for(auto &e:g[v]) es.emplace_back(e);
	vector<Weight> dist(n,inf);
	dist[s] = 0;

	bool negCycle = false;
	for(int i=0;;i++){
		bool update = false;
		for(auto &e:es)
			if(dist[e.src]!=inf && dist[e.dst] > dist[e.src]+e.weight){
				dist[e.dst] = dist[e.src]+e.weight;
				update = true;
			}
		if(!update) break;
		if(i>n){
			negCycle = true;
			break;
		}
	}
	return make_pair(dist,!negCycle);
}

//////////

void out(bool ans){
	if(ans == true) cout << "yes" << endl;
	else cout << "no" << endl;
}
void Out(bool ans){
	if(ans == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}
void OUT(bool ans){
	if(ans == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}

//// Mathematical functions
ll gcd(const ll a, const ll b){
	return (b==0) ? a : gcd(b,a%b);
}
ll lcm(const ll a, const ll b){
	return a*(b/gcd(a,b));
}
ll Manhattan_dist(ll x1, ll y1, ll x2, ll y2){
	return abs(x1-x2) + abs(y1-y2);
}
// nをpで何回割れるか
ll hmt_p_divide_n(ll p, ll n){
	ll s = 0;
	while(n%p == 0){
		n /= p;
		s++;
	}
	return s;
}
int digit(ll n){
	int cntr = 0;
	while(n>0){
		n/=10;
		cntr++;
	}
	return cntr;
}
// generarized absolute value
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

// unsigned long long nCr(int n, int r){
// 	unsigned long long ans = 1;
// 	for(int i=n; i>n-r; --i) ans*=i;
// 	for(int i=1; i<r+1; ++i) ans/=i;
// 	return ans;
// }

unsigned long long memo[100][100] = {};
unsigned long long nCr(const int n, const int r){
	if(n<r) return 0;
	if(r==0 || n==r) return 1;
	if(memo[n][r]>0) 
		return memo[n][r];
	else
		return memo[n][r] = nCr(n-1,r) + nCr(n-1,r-1);
}
ll pw(ll x, int y) {
	ll a = 1;
	while(y){
		if(y&1)
			a = (a*x)%mod; 
		x = (x*x)%mod;
		y >>= 1;
	}
	return a;
}
ll modinv(ll x){
	return pw(x, mod-2);
}

//////////////////////////////////////////////////
//////////////////////////////////////////////////
//////////////////////////////////////////////////


int main(){
	int N;
	cin >> N;
	vector<Edge> init;
	Graph g(N,init);
	int a,b,w;
	rep(i,N-1){
		cin >> a>>b>>w;
		add_edge(g,a-1,b-1,w);
	}
	// show_weighted_graph(g);

	int Q,K;
	cin >>Q>>K;

	const ll inf = 1e13;
	ll dist[N] = {}; // 頂点Kから各ノードiへの距離
	rep(i,N)
		dist[i] = 0;
	// dist[K] = 0;

	bool visited[N] = {};
	stack<int> S;
	S.push(K-1);
	while(!S.empty()){
		int v = S.top();
		S.pop();
		visited[v]=true;
		for(auto e:g[v])
			if(!visited[e.dst]){
				dist[e.dst] = dist[v]+e.weight;
				S.push(e.dst);
			}
	}
	// rep(i,N)
	// 	cout << dist[i] << " ";
	// cout << endl;

	int x,y;
	rep(i,Q){
		cin >> x >> y;
		cout << dist[x-1]+dist[y-1] <<endl;
	}

}


Measured memory_bytes: 11520