// Slower C++ solution:


//include

//------------------------------------------

#include <vector>

#include <list>

#include <map>

#include <set>

#include <deque>

#include <queue>

#include <stack>

#include <bitset>

#include <algorithm>

#include <functional>

#include <numeric>

#include <utility>

#include <sstream>

#include <iostream>

#include <fstream>

#include <iomanip>

#include <cstdio>

#include <cmath>

#include <cstdlib>

#include <string>

#include <cstring>

#include <ctime>





using namespace std;



//conversion

//------------------------------------------

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }

template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }



//math

//-------------------------------------------

template<class T> inline T sqr(T x) { return x * x; }



//typedef

//------------------------------------------

typedef vector<int> VI;

typedef vector<VI> VVI;

typedef vector<string> VS;

typedef pair<int, int> PII;

typedef long long LL;



//container util

//------------------------------------------

#define ALL(a)  (a).begin(),(a).end()

#define RALL(a) (a).rbegin(), (a).rend()

#define PB push_back

#define MP make_pair

#define SZ(a) int((a).size())

#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)

#define EXIST(s,e) ((s).find(e)!=(s).end())

#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)

#define SORT(c) sort((c).begin(),(c).end())



//repetition

//------------------------------------------

#define FOR(i,a,b) for(int i=(a);i<(b);++i)

#define rep(i,n)  FOR(i,0,n)

#define loop(n) FOR(i,0,n)

#define rrep(i,a,b) for(int i=(a);i>=(b);--i)

//constant

//--------------------------------------------

const double EPS = 1e-10;

const double PI = acos(-1.0);

const int INF = (int)1000000007;

const LL MOD = (LL)1000000007;//10^9+7

const LL INF2 = (LL)100000000000000000;//10^18



const int limit = 100010;



using edge = struct { int to; LL cost; };



vector<edge> tree[limit];

LL depth[limit];



void dfs(int v, int p, LL d) {

	depth[v] = d;



	for (auto &e : tree[v]) {

		if (e.to == p)continue;

		dfs(e.to, v, d + e.cost);

	}

}



int main() {

	int n; cin >> n;







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

		int a, b, c;

		cin >> a >> b >> c;

		a--; b--;

		

		tree[a].push_back({ b,c });

		tree[b].push_back({ a,c });



	}



	int q, k;

	cin >> q >> k;

	k--;



	dfs(k, -1, 0);



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

		int x, y;

		cin >> x >> y;



		x--; y--;



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

	}

}

// Faster C++ solution for the same problem (measured speedup: 3.4623066781529297x):


//include

//------------------------------------------

#include <vector>

#include <list>

#include <map>

#include <set>

#include <deque>

#include <queue>

#include <stack>

#include <bitset>

#include <algorithm>

#include <functional>

#include <numeric>

#include <utility>

#include <sstream>

#include <iostream>

#include <fstream>

#include <iomanip>

#include <cstdio>

#include <cmath>

#include <cstdlib>

#include <string>

#include <cstring>

#include <ctime>

#include <limits>



using namespace std;



//conversion

//------------------------------------------

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }

template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }



//math

//-------------------------------------------

template<class T> inline T sqr(T x) { return x * x; }



//typedef

//------------------------------------------

typedef vector<int> VI;

typedef vector<VI> VVI;

typedef vector<string> VS;

typedef pair<int, int> PII;

typedef long long LL;



//container util

//------------------------------------------

#define ALL(a)  (a).begin(),(a).end()

#define RALL(a) (a).rbegin(), (a).rend()

#define PB push_back

#define MP make_pair

#define SZ(a) int((a).size())

#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)

#define EXIST(s,e) ((s).find(e)!=(s).end())

#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)

#define SORT(c) sort((c).begin(),(c).end())



#define REP(i,n) for(int i=0;i<(int)n;++i)

#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)



//constant

//--------------------------------------------

const double EPS = 1e-10;

const double PI = acos(-1.0);

const int INF = (int)1000000007;

const LL MOD = (LL)1000000007;//10^9+7

const LL INF2 = (LL)100000000000000000;//10^18







template< typename T >

struct edge {

	int src, to;

	T cost;



	edge(int to, T cost) : src(-1), to(to), cost(cost) {}



	edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}



	edge &operator=(const int &x) {

		to = x;

		return *this;

	}



	operator int() const { return to; }

};



template< typename T >

using Edges = vector< edge< T > >;

template< typename T >

using WeightedGraph = vector< Edges< T > >;



template< typename T >

vector< T > dijkstra(WeightedGraph< T > &g, int s) {

	const auto INF = numeric_limits< T >::max();

	vector< T > dist(g.size(), INF);



	using Pi = pair< T, int >;

	priority_queue< Pi, vector< Pi >, greater< Pi > > que;

	dist[s] = 0;

	que.emplace(dist[s], s);

	while (!que.empty()) {

		T cost;

		int idx;

		tie(cost, idx) = que.top();

		que.pop();

		if (dist[idx] < cost) continue;

		for (auto &e : g[idx]) {

			auto next_cost = cost + e.cost;

			if (dist[e.to] <= next_cost) continue;

			dist[e.to] = next_cost;

			que.emplace(dist[e.to], e.to);

		}

	}

	return dist;

}



int main() {

	LL V, E;

	cin >> V;

	E = V - 1;



	WeightedGraph< LL > g(V);

	vector<LL> x(E);

	vector<LL> y(E);

	vector<LL> z(E);

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

		cin >> x[i] >> y[i] >> z[i];

		//1indexedなら--して

		x[i]--; y[i]--;

		g[x[i]].emplace_back(y[i], z[i]);

		g[y[i]].emplace_back(x[i], z[i]);

	}



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

	k--;

	auto dist=dijkstra(g,k);



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

		int n, m; cin >> n >> m;

		n--; m--;



		cout << dist[n]+dist[m] << endl;

	}





   //dist == numeric_limits< LL >::max()

   //for (auto &dist : dijkstra(g, R)) {



   //}

}