#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<fcntl.h>
#include<unistd.h>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

struct Graph{
    struct Edge{
        int cost, from, dest;
        Edge(int cost, int dest): cost(cost), from(-1), dest(dest){ }
        Edge(int cost, int from, int dest): cost(cost), from(from), dest(dest){ }
        ostream& operator >> (ostream& out){
            return out << '(' << cost << ':' << from << ' ' << dest << ')';
        }
    };
    struct Node{
        vector<Edge> edges;
    };
    vector<Node> nodes;
    Graph(int num): nodes(num){ }
    void addEdge(int from, int dest, int cost = 1){
        nodes[from].edges.emplace_back(cost, dest);
    }
    void addEdge2(int from, int dest, int cost = 1){
        addEdge(from, dest, cost);
        addEdge(dest, from, cost);
    }
    ll dijkstra2(int start, vector<ll> &lens){
        struct DElem{
            ll cost, dest;
            bool operator < (const DElem& e) const { return cost > e.cost; }
        };
        priority_queue<DElem> pq;
        pq.push({0, start});
        while(pq.size()){
            auto e = pq.top(); pq.pop();
            if(lens[e.dest] <= e.cost){ continue; }
            lens[e.dest] = e.cost;
            for(auto& edge : nodes[e.dest].edges){
                if(lens[edge.dest] > e.cost + edge.cost){
                    pq.push({e.cost + edge.cost, edge.dest});
                }
            }
        }
        return -1;
    }
};

template <int size>
struct Buffer{
    int idx = 0;
    char buf[size];
    Buffer(){
        cin.read(buf, size - 1);
    }
    int next(){
        int ret = 0;
        while(!isdigit(buf[idx])){ idx++; }
        while(isdigit(buf[idx])){ ret = ret * 10 + buf[idx++] - '0'; }
        return ret;
    }
};
Buffer<(int)4e6> buf;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    // read(STDIN_FILENO, buf, sizeof(buf) - 1);
    int n = buf.next();
    Graph g(n);
    for(int i = 0; i < n - 1; i++){
        int a = buf.next(), b = buf.next(), c = buf.next();
        a--; b--;
        g.addEdge2(a, b, c);
    }
    int q = buf.next(), k = buf.next();
    k--;
    vector<ll> lens(n, MLL);
    g.dijkstra2(k, lens);
    prints(lens);
    for(int i = 0; i < q; i++){
        int x = buf.next(), y = buf.next();
        x--; y--;
        cout << lens[x] + lens[y] << '\n';
    }

    // int n; cin >> n;
    // Graph g(n);
    // for(int i = 0; i < n - 1; i++){
    //     int a, b, c;
    //     cin >> a >> b >> c;
    //     a--; b--;
    //     g.addEdge2(a, b, c);
    // }
    // int q, k;
    // cin >> q >> k;
    // k--;
    // vector<ll> lens(n, MLL);
    // g.dijkstra2(k, lens);
    // prints(lens);
    // for(int i = 0; i < q; i++){
    //     int x, y;
    //     cin >> x >> y;
    //     x--; y--;
    //     cout << lens[x] + lens[y] << '\n';
    // }
}


Measured memory_bytes: 13620