#pragma region header
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a / gcd(a, b) * b ;
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion

struct edge{int to,cost;};
vector<vector<edge>> G(100100);
int dist[100100];
void dijkstra(int s) {
    fill(dist,dist+100100,INF);
    priority_queue<P,vector<P>,greater<P>> pri;
    dist[s]=0;
    pri.push({0,s});
    while(!pri.empty()) {
        P p = pri.top();pri.pop();
        int v = p.second;
        if(dist[v]<p.first) continue;
        for(auto e:G[v]) if(chmin(dist[e.to],dist[v]+e.cost)) pri.push({dist[e.to],e.to});
    }
}
signed main() {
    int n;cin >> n;
    rep(i, n-1) {
        int a,b,c;cin >> a >> b >> c;
        a--;b--;
        G[a].pb({b,c});
        G[b].pb({a,c});
    }
    int q,k;cin >> q >> k;
    dijkstra(--k);
    rep(i, q) {
        int a,b;cin >> a >> b;
        cout << dist[--a]+dist[--b] << char(10);
    }
    return 0;
}
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_N = 212345;
vector<pair<int,int>> g[MAX_N];

ll dist[MAX_N];

void dfs(int u, int prev, ll cur_dist) {
  dist[u] = cur_dist;
  for (auto e : g[u]) if (e.first != prev) {
    dfs(e.first, u, cur_dist + e.second);
  }
}
int main2() {
  REP(i, MAX_N) g[i].clear();
  int N = nextLong();

  REP(i, N-1) {
    int a = nextLong() - 1;
    int b = nextLong() - 1;
    ll c = nextLong();
    g[a].push_back({b, c});
    g[b].push_back({a, c});
  }

  int Q = nextLong();
  int K = nextLong() - 1;
  dfs(K, -1, 0);
  REP(_, Q) {
    int x = nextLong() - 1;
    int y = nextLong() - 1;
    ll ans = dist[x] + dist[y];
    cout << ans << '\n';
  }
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}