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

#include <vector>

#include <algorithm>

#include <string>

#include <map>

#include <cmath>

#include <queue>

#include <numeric>

#include <climits>

#include <iterator>

#include <iomanip>

#include <stack>

#include <set>

#include <cstdio>

#include <bitset>

#include <functional>

#include <tuple>

#include <list>

#include <deque>

#include <sstream>

using namespace std;

const constexpr int INF = 1e9;

typedef pair<int, int> P;



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

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



typedef long long ll;

typedef vector<int> VI;



struct Less{

   bool operator()(const pair<string, int>&a, const pair<string, int>&b){

        if(a.first==b.first){

            return a.second < b.second;

        }

       return a.first < b.first;

    }

};

const constexpr ll MOD = 1e9 + 7;

struct NODE{

    ll to, cost;

};

ll Q, K; 

ll dist[100010]; //点Kからある点に到着するのにかかるコスト

vector<vector<NODE>> v(100010);

bool check[100010];

void dfs(ll pos, ll sum){

    if(check[pos]) return;

    check[pos] = true;

    dist[pos] += sum;

    for(int i=0; i<v[pos].size(); ++i){

        dfs(v[pos][i].to, v[pos][i].cost+sum);   

    }

    

    

}



int main() {

    ll N; cin >> N;

    REP(i, N-1){

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

        a--; b--;

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

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

    }

    cin >> Q >> K;

    K--;

    for(int i=0; i<100010; ++i) dist[i]=0;

    for(int i=0; i<100010; ++i) dist[i] = false;

    dfs(K, 0);

    

    

    REP(i, Q){

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

        x--; y--;

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

    }

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.256567940878339x):
#include <bits/stdc++.h>

 

const double pi = 3.141592653589793238462643383279;

using namespace std;

//typedef

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

typedef vector<int> VI;

typedef vector<VI> VVI;

typedef vector<string> VS;

typedef pair<int, int> PII;

typedef pair<long long, long long> PLL;

typedef pair<int, PII> TIII;

typedef long long LL;

typedef unsigned long long ULL;

typedef vector<LL> VLL;

typedef vector<VLL> VVLL;

 

 

//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 SQ(a) ((a)*(a))

#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 SORT(c) sort((c).begin(),(c).end())

 

 

//repetition

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

#define FOR(i,s,n) for(int i=s;i<(int)n;++i)

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

#define MOD 1000000007

 

 

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

#define trav(a, x) for(auto& a : x)

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

#define sz(x) (int)(x).size()

 

typedef long long ll;

typedef pair<int, int> pii;

typedef vector<int> vi;

const double EPS = 1E-10;

 

#define chmin(x,y) x=min(x,y)

#define chmax(x,y) x=max(x,y)





//ここから編集



vector<vector<pii>> g(100010);

int main() {

  cin.tie(0);

  ios::sync_with_stdio(false);

  cout << fixed << setprecision(10);

  

  int N; cin >> N;

  REP(i,N-1){

    int a, b, c; cin >> a >> b >> c;

    a--; b--;

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

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

  }



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

  K--;

  vector<ll> dist(N, (1LL<<60));

  dist[K] = 0;

  priority_queue<PLL, vector<PLL>, greater<PLL>> q;

  q.push({0, K});

  while(q.size()){

    auto p = q.top();

    q.pop();



    int v = p.second;

    ll cost = p.first;

    if(dist[v] < cost) continue;



    for(auto e: g[v]){

      if(dist[e.first] > dist[v] + e.second){

        dist[e.first] = dist[v] + e.second;

        q.push({dist[e.first], e.first});

      }

    }

  }



  REP(i,Q){

    int x, y; cin >> x >> y;

    x--; y--;

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

  }

  return 0;

}