/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

#ifndef DEFINE_DIJKSTRA_HPP
#define DEFINE_DIJKSTRA_HPP

template<typename T>
class Dijkstra
{
    struct edge {
        int to;
        T cost;
        edge(int t, T c) : to(t),cost(c){}
    };
    typedef pair<T, int> P;
public:
    int n;
    vector<edge> g[100010];
    vector<ll> dist;
    Dijkstra(int n): n(n){};

    void add(int from, int to, T cost)
    {
        g[from].push_back(edge(to, cost));
    };

    void build(int s)
    {
        priority_queue<P, vector<P>, greater<P>> q;
        dist.assign(n+1, inf);
        dist[s] = 0;
        q.push(P(0, s));
        while(!q.empty()){
            P p = q.top();
            q.pop();
            int v = p.second;
            if(dist[v] < p.first) continue;
            for(auto const& e : g[v]) {
                if(dist[e.to] > dist[v] + e.cost){
                    dist[e.to] = dist[v] + e.cost;
                    q.push(P(dist[e.to], e.to));
                }
            }
        }
    }

    T result(int s)
    {
        return dist[s];
    }
};

#endif  //DEFINE_DIJKSTRA_HPP

// verify
// https://atcoder.jp/contests/abc070/tasks/abc070_d


class DTransitTreePath {
public:
	void solve(std::istream& in, std::ostream& out)
	{
        int n, a, b;
        ll c;
        in >> n;
        Dijkstra<ll> dk(n);
        for(int i=0; i<n-1; i++){
            in >> a >> b >> c;
            dk.add(a, b, c);
            dk.add(b, a, c);
        }
        int q, k, x, y;
        in >> q >> k;
        dk.build(k);
        for(int i=0; i<q; i++){
            in >> x >> y;
            out << dk.result(x) + dk.result(y) << endl;
        }
	}
};


int main() {
	DTransitTreePath solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 11120