// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<vector>

#include<stack>

#include <cmath>

#include <limits>

#include<set>

#include <iomanip>

#include <queue>

#include <string>

#pragma GCC optimize("Ofast")

using namespace std;

const long long INF=20000000000;

//setprecision(2) <<



const int MOD = 1000000007;



long long max(long long a,long long b){

	if(a<b)return b;

	else return a;	

}

long long min(long long a,long long b){

	if(a>b)return b;

	else return a;	

}

long long gcd(long long a,long long b){

	if(a<b)swap(a,b);

	if(a%b==0)return b;

	else return gcd(a%b,b);

}



long long lcm(long long a,long long b){

	return a*b/gcd(a,b);

}





long long getDigit(long long n){

	if(n==1)return 1;

	else return log10(n)+1;

}



class Point{

public:

	long long x;

	long long y;

};

long long N,M;

vector<long long>X(100006,0);

bool isOK(long long time){

	long right=0;

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

		if(right>=X[i]-1){

			//go right

			right=X[i]+time;

		}else{

			if(right < X[i]-time-2)return false;

			right=max(X[i],X[i]+(time-(2*(X[i]-right)-1)));

		}

		//cout<<right<<endl;

	}

	if(right<N-1)return false;

	return true;

	

}

int main(){

	ios::sync_with_stdio(false);

	cin.tie(nullptr);

	long long N;

	cin>>N;

	vector<bool>ex(N+1,false);

	vector<long long>d(N+1,INF);

	vector<pair<long long,long long>>G[N+1];

	

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

		long long a,b,w;

		cin>>a>>b>>w;

		G[a].push_back(make_pair(b,w));

		G[b].push_back(make_pair(a,w));

	}

	long long K,Q;

	cin>>Q>>K;

	d[K]=0;

	stack<long long>que;

	que.push(K);

	while(!que.empty()){

		long long u=que.top();

		que.pop();

		long long size=G[u].size();

		ex[u]=true;

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

			long long v=G[u][i].first;

			if(ex[v]==false){

				d[v]=d[u]+G[u][i].second;

				que.push(v);

			}

		}

	}

	/*for(int i=1;i<=N;i++)cout<<i<<" "<<d[i]<<endl;*/

	

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

		long long x,y;

		cin>>x>>y;

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

	}

}


// Faster C++ solution for the same problem (measured speedup: 1.7953832114907657x):
#include<iostream>

#include<algorithm>

#include<vector>

#include<stack>

#include <cmath>

#include <limits>

#include<set>

#include <iomanip>

#include <queue>

#include <map>

#include <string>

#pragma GCC optimize("Ofast")

using namespace std;

typedef long long ll;

const long long INF=(1LL<<62);

const double inf=pow(10,10);

double pi=3.141592653589793;

const int dx[4]={0,1,0,-1};

const int dy[4]={1,0,-1,0};

const ll MOD = 1000000007;

void init(){

	ios::sync_with_stdio(false);

	cin.tie(nullptr);

}



long long gcd(long long a,long long b){

	if(a<b)swap(a,b);

	if(a%b==0)return b;

	else return gcd(a%b,b);

}



long long lcm(long long a,long long b){

	return a/gcd(a,b)*b;

}



int main(){

	init();

	ll N;cin>>N;

	vector<pair<ll,ll>>G[N];

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

		ll a,b,c;cin>>a>>b>>c;

		a--;b--;

		G[a].push_back(make_pair(b,c));

		G[b].push_back(make_pair(a,c));

	}

	

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

	

	//dis K and i

	queue<pair<ll,ll>>que;

	vector<ll>d(N,0);

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

	vector<bool>ex(N,false);

	ex[K]=true;

	

	while(!que.empty()){

		ll u=que.front().first;

		ll dis=que.front().second;

		d[u]=dis;

		que.pop();

		for(int i=0;i<G[u].size();i++){

			ll next = G[u][i].first;

			//cout<<" next"<<next<<endl;

			if(ex[next])continue;

			ex[next]=true;

			que.push(make_pair(next,dis+G[u][i].second));

		}

	}

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

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

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

	}

}