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

#include<vector>

#include<queue>

#include<stack>

#include<list>

#include<string>

#include<cmath>

#include<algorithm>

#include<bitset>

#include<map>

#include<functional>



using namespace std;



#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)

#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)

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

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

typedef long long int ll;

typedef long double ld;

typedef vector<ll> vll;

typedef vector<string> vs;

typedef pair<ll, ll> pll;



ll n = 0, m = 0, k = 0, ans = 0, sum = 0, cnt = 0, temp = 0;

string s;

bool flag;



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



#define MAX 110000



#define INF 11111111111111111

#define NOT 0

#define VIS 1

#define COMP 2



ll stt[MAX];

ll mini[MAX];

vector<pll> edge[MAX];

priority_queue<pll, vector<pll>, greater<pll>> pq;



void dijkstra(ll start) {

  pll min;

  FOR(i, 1, n + 1) {

	stt[i] = NOT;

	mini[i] = INF;

  }

  mini[start] = 0;

  pq.push(make_pair(0, start));



  while (!pq.empty()) {

	min = pq.top();

	pq.pop();

	m = min.second;

	stt[m] = COMP;



	if (mini[m] < min.first) continue;



	FOR(i, 0, edge[m].size()) {

	  k = edge[m][i].first;

	  if (stt[k] != COMP) {

		if (edge[m][i].second + mini[m] < mini[k]) {

		  mini[k] = edge[m][i].second + mini[m];

		  stt[k] = VIS;

		  pq.push(make_pair(mini[k], k));

		}

	  }

	}

  }



}



int main(void) {

  ll a, b, c, q, x, y;

  cin >> n;



  FOR(i, 0, n - 1) {

	cin >> a >> b >> c;

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

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

  }



  cin >> q >> k;



  dijkstra(k);



  FOR(i, 0, q) {

	cin >> x >> y;

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

  }



  return 0;

}

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

#include<vector>

#include<queue>

#include<stack>

#include<string>

#include<cmath>

#include<algorithm>

#include<bitset>

#include<map>

#include<functional>

#include<set>



#pragma region

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)

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

#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)

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

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

#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;

#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);

#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);

#define scan(x) scanf("%lld",&x);

#define inf 5555555555555555555

#define mod 1000000007

#define pi 3.14159265358979323846

#define pb push_back

typedef long long int ll;

typedef vector<ll> vll;

typedef vector<vll> vvll;

typedef pair<ll, ll> pll;

typedef vector<pll> vpll;

typedef map<ll, ll> MAP;

typedef set<ll> SET;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;

string s;

bool ok, flag;

ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };

ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };

#pragma endregion

#define MAX 111111



struct Weighted_Graph {

  struct edge { ll node, cost; };

  vector<vector<edge>> e;



  void set(ll x) {

	e.resize(x + 1);

  }



  void add_edge(ll a, ll b, ll c) { e[a].pb(edge{ b,c }); }



  vll dijkstra(ll start) {

	priority_queue<pll, vector<pll>, greater<pll>> pq;

	ll u;

	pll p;

	vll dist(e.size(), inf);

	dist[start] = 0;

	pq.push(pll(0, start));



	while (!pq.empty()) {

	  p = pq.top(); pq.pop();

	  u = p.second;

	  if (dist[u] < p.first) continue;

	  for (edge e1 : e[u]) {

		if (dist[e1.node] > dist[u] + e1.cost) {

		  dist[e1.node] = dist[u] + e1.cost;

		  pq.push(pll(dist[e1.node], e1.node));

		}

	  }

	}

	return dist;

  }



};





int main(void) {

  cin >> n;

  Weighted_Graph wg;

  vll d;

  ll a, b, c, q, k;

  wg.set(n);

  rep(i, n - 1) {

	scan(a); scan(b); scan(c);

	wg.add_edge(a, b, c);

	wg.add_edge(b, a, c);

  }

  cin >> q >> k;

  d = wg.dijkstra(k);



  rep(i, q) {

	scan(a); scan(b);

	cout << d[a] + d[b] << endl;

  }



  return 0;

}