// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



typedef long long int ll;

typedef pair<ll, ll> pll;



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

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

#define OF64 std::setprecision(10)



const ll MOD = 1000000007;

const ll INF = (ll)1e15;



struct Vertex

{

    vector<pll> e;

};



Vertex V[100005];

//! Kまでのコスト

ll C[100005];



int main()

{

    int N;

    cin >> N;

    REP(i, N - 1)

    {

        ll a, b, c;

        cin >> a >> b >> c;

        a--;

        b--;

        V[a].e.push_back(pll(b, c));

        V[b].e.push_back(pll(a, c));

    }

    REP(i, N)

    {

        C[i] = INF;

    }



    int Q, K;

    cin >> Q >> K;

    K--;

    C[K] = 0;

    queue<ll> q;

    q.push(K);

    while (!q.empty())

    {

        ll t = q.front();

        q.pop();

        REP(i, V[t].e.size())

        {

            pll e = V[t].e[i];

            if (C[t] + e.second >= C[e.first])

                continue;

            C[e.first] = C[t] + e.second;

            q.push(e.first);

        }

    }



    REP(i, Q)

    {

        int x, y;

        cin >> x >> y;

        x--;

        y--;

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

    }

    return 0;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>



using namespace std;



typedef long long int ll;

typedef pair<ll, ll> pll;



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

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

#define OF64 std::setprecision(10)



const ll MOD = 1000000007;

const ll INF = (ll) 1e15;



struct RootedTree {

    RootedTree(int n, int root = 0) :

            mRoot(root) {

        mVertexTbl.resize(n);

    }



    void addEdge(int a, int b, long long int cost = 1) {

        mVertexTbl[a].child.push_back(pair<int, long long int>(b, cost));

        mVertexTbl[b].child.push_back(pair<int, long long int>(a, cost));

    }



    void build() {

        queue<tuple<int, int, long long int>> q;

        q.push(make_tuple(mRoot, -1, 0));

        while (!q.empty()) {

            auto t = q.front();

            q.pop();

            int index = get<0>(t);

            int parent = get<1>(t);

            long long int depth = get<2>(t);

            mVertexTbl[index].parent = parent;

            mVertexTbl[index].depth = depth;

            for (auto it = mVertexTbl[index].child.begin(); it != mVertexTbl[index].child.end();) {

                int nxt = (*it).first;

                if (nxt == parent) {

                    mVertexTbl[index].child.erase(it);

                    continue;

                }

                q.push(make_tuple(nxt, index, depth + (*it).second));

                ++it;

            }

        }

    }



    vector<int> getLeaf() {

        vector<int> leafs;

        for (int i = 0; i < mVertexTbl.size(); ++i) {

            if (mVertexTbl[i].child.size() == 0)

                leafs.push_back(i);

        }

        return leafs;

    }



    struct Vertex {

        vector<pair<int, long long int>> child;

        long long int depth = 0;

        int parent = -1;

    };



    int mRoot;

    vector<Vertex> mVertexTbl;

};



int main() {

    ll N;

    cin >> N;

    RootedTree tree(N);

    REP(i, N - 1) {

        ll a, b, c;

        cin >> a >> b >> c;

        a--;

        b--;

        tree.addEdge(a, b, c);

    }



    ll Q, K;

    cin >> Q >> K;

    K--;

    tree.mRoot = K;

    tree.build();

    REP(_, Q) {

        ll x, y;

        cin >> x >> y;

        x--;

        y--;

        cout << tree.mVertexTbl[x].depth + tree.mVertexTbl[y].depth << endl;

    }

    return 0;

}

// Fastest known solution for this problem: